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 <conio.h>
# include <process.h>

class stack
{
 int arr[50];
 int top;
 public:
    int get_top();
    stack()
    {
     top=-1;
    }
    void push(int);
    int pop();
    void peep();
};
int display_menu();
int stack :: get_top()
{
 return(top);
}
void stack :: push(int no)
{
  arr[top+1]=no;
  top=top+1;
}

int stack :: pop()
{
  int no;
  if(top<0)
  {
   return(NULL);
  }
  else
  {
  no=arr[top];
  top=top-1;
  return(no);
  }
}

void stack :: peep()
{
  if(top>=0)
  {
    for(int i=top;i>=0;i--)
    {
        cout<<\"Stack [\"<<i<<\"] :\"<<arr[i]<<endl;
    }
  }







  else
  {
     cout<<\"Empty Stack !!!\"<<endl;
  }
}

void main()
{
 stack s1;
 while(1)
 {
  switch(display_menu())
  {
   case 1: cout<<\"Enter Number to push :\";
       int no;
       cin>>no;
       s1.push(no);
       s1.peep();
       getch();
       break;
   case 2:
       no=s1.pop();
       if(no!=NULL)
       {
        cout<<\"Stack [\"<<s1.get_top()+1<<\"] :\"<<no;
       }
       else
       {
        cout<<\"Empty Stack !!!\"<<endl;
       }
       getch();
       break;
   case 3: s1.peep();
       getch();
       break;
   case 4: exit(1);

  }
 }
}

int display_menu()
{
 clrscr();
 int ch;
 cout<<endl;
 cout<<\"\\t\\t\\t| 1 | : PUSH\"<<endl;
 cout<<\"\\t\\t\\t| 2 | : POP\"<<endl;
 cout<<\"\\t\\t\\t| 3 | : PEEP\"<<endl;
 cout<<\"\\t\\t\\t| 4 | : Exit\"<<endl;
 cout<<\"\\t\\t\\tEnter Your Choice :\";
 cin>>ch;
 return(ch);
}

    Related Post:
  1. Program to illustrate strings as member of classes

  2. Program to illustrate the overloading of constructors in classes

  3. Program to fill different types of geometric shapes using Boundary Fill Algorithm (Using Linked-List)

  4. Tic-Tac-Toe game

  5. Program to illustrate the implementation of Rotation Transformation

  6. Program to tokenized a given string

  7. Code for finding a no in a binary search tree and displaying its level where it is found (root is at zero level)

  8. Program that reads a number ,coumputes and displays its factorial using do-while loop

  9. Program of cohen sutherland Line clipping Algorithm

  10. Program to estimate the value of First Derivative of the function at the given points from the given data using Central Difference Formula

  11. Program that takes input of 2 matrix rows and columns data and displays addition of it using + operator overloading

  12. Program to show find the maximum depth of a Binary Search Tree

  13. Program to reverse the sequence of the words in the sentence and display the result

  14. Program to computes the n_th term of the fibonacci series using Divide and Conquer Strategy

  15. Library System

  16. Program to create a circular linked list

  17. Program to implement the Kurskals Algorithm to solve Minimum Cost Spanning Tree Problem (MST) using Graphics with Mouse Support

  18. Menu driven Bank Application Project

  19. Program to construct Newtons Divided Difference Interpolation Formula from the given distinct data points and estimate the value of the function

  20. Program to illustrate operator overloading from String object to basic string

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