C++ Programming Tutorial

 
 
 

Data File Structure Programs

Array

Insert, edit, delete, append, display, Srch. Insert, delete, merge, delete multiple occurrences Arrays as a Stack in graphics

Stack

Stack operations using array Stack using static memory allocation Stack using dynamic memory allocation Double ended link list as a stack Lnked list as a Stack Infix expr. to Postfix expr. Postfix expr. into an Infix expr. Arrays as a Stack in graphics Stack as an Arithmetic expr. Evaluater Graphical Rep. of Stack Stack to traverse - inodr, postodr, preodr

Queue

Queue using static memory allocation Queue using dynamic memory allocation Circular queue Linked list as a Queue Double Ended linked list as a Queue Graphical Rep. of Queue Arrays as a Linear Queue Array as a Circular Queue Arrays as a Linear Queue ( in graphics ) Arrays as a Circular Queue ( in graphics )

Linked List

Singly link list Circular linked list Doubly link list Linked list as a Queue Linked list as a Stack Double Ended linked list as a Queue Double Ended linked list as a Stack Infix to Postfix - Linked List as Stack Circular doubly link list Single Ended Linked List - Sorting in both odr Hashing - double ended Linked List Sort of link list

Tree

Linked List as a Binary Srch. Tree Set Class using Binary Srch. Tree Maximum depth of Binary Srch. Tree Minimum Spaning Tree Prims algo - minimum spanning tree Traverse binary tree - inodr, preodr, post Find number in binary Srch. tree display levell

Sorting

Bubble Sort Selection Sort Insertion Sort Radix Sort Merge Sort Quick Sort Heap Sort Linear Sort Shell Sort Topological Sort

Searching

Linear Srch. or Sequential Srch. Binary Search Breadth First Search Traversal Depth First Search Traversal Shortest Path-Given Source-Destination-Dijkstras

Hashing

Simple implementation of Hashing Hashing using double-ended Linked List Hashing using Mid-Square Method Example of Hashing n term of the fibonacci series using recursion

Recursion

Factorial of the given number using recursion Mystery of Towers of Hanoi using recursion
 
 

Image

# include <iostream.h>
# include <process.h>
# include <conio.h>
# include <malloc.h>

struct link_list
{
 int no;
 struct link_list *next;
};
class stack
{
 link_list *list,*head;
 public:
    stack()
    {
     head=NULL;
     free(list);
    }
    void push();
    void peep();
    void pop();
};

void stack :: push()
{
  link_list *newnode;
  newnode=new link_list;
  cout<<\"Enter Number to push :\";
  cin>>newnode->no;
  list=head;
  if(head==NULL)
  {
    head=newnode;
    newnode->next=NULL;
  }
  else
  {
    newnode->next=list;
    list=newnode;
    head=newnode;
  }
}

void stack :: peep()
{
 cout<<endl;
  if(head==NULL)
 {
  cout<<\"Empty Stack !!!\";
  return;
 }
 list=head;








 while(list!=NULL)
 {
  cout<<list->no<<\"\\t\";
  list=list->next;
 }
}

void stack :: pop()
{
 cout<<endl;
 if(head==NULL)
 {
  cout<<\"Empty Stack !!!\";
  return;
 }
 else
 {
  cout<<\"Top : \"<<head->no<<endl;
  head=head->next;
 }
}

int display_menu()
{
 int ch;
 clrscr();
 cout<<endl;
 cout<<\"[ 1 ] Push\"<<endl;
 cout<<\"[ 2 ] Pop\"<<endl;
 cout<<\"[ 3 ] Peep\"<<endl;
 cout<<\"[ 4 ] Exit\"<<endl;
 cout<<\"Enter your choice :\";
 cin>>ch;
 return ch;
}
void main()
{
 stack s1;
 while(1)
 {
  switch(display_menu())
  {
   case 1:s1.push();
      break;
   case 2:s1.pop();
      getch();
      break;
   case 3:s1.peep();
      getch();
      break;
   case 4: exit(1);
  }
 }
}

    Related Post:
  1. Program to construct Newtons Backward Difference Interpolation Formula from the given distinct equally spaced data points

  2. Program of polyline translation.

  3. Program to illustrate the role of destructor in classes

  4. Matrix Addition Program

  5. Program of addition and subtraction of large numbers

  6. Program to perform array operations like append, insert, delete, edit, display and search and element

  7. Program that takes 10 integer from a user and perform addition using class

  8. Program of Binary Search Tree Operations

  9. Program to illustrate operator overloading from class to basic type

  10. Program to perform stack operations using array

  11. Program that reads a number and displays it with its digits in reverse order using do-while loop

  12. Program that reads marks obtained by a student in a test of 100 marks and computes his grade

  13. Program to count number of words, lines and characters in given string

  14. Program to draw a line using Cartesian Slope-Intercept Equation

  15. Program of circular doubly link list with insert, append, delete, copy, reverse and display operations

  16. Program to implement a Translator that reads an Infix Expression translates it into a Postfix Expression and evaluate the Postfix Expression

  17. Program of Midpoint Circle Drawing

  18. Program to read a Linear System of Equations,then evaluate it by using Guass-Seidel Itrative Method and show the result

  19. Program to read marks of 10 students for 4 subjects and compute and display total marks and status of each student

  20. Program to show the use of Bitwise Operator XOR ( ^ )

 
 
Didn't find what you were looking for? Find more on Program to create a stack using dynamic memory allocation