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 perform merge sort

  2. PROGRAM FOR ACCEPTING MEASUREMENTS IN METERS AND FEETS AND SUMMING THEM UP IN THE FORMAT THAT THE USER WISHES

  3. Program to illustrate the implementation of Translation Transformation.

  4. Program to convert a decimal number into binary, octal and pental code

  5. Program to illustrate the use of pointer to pointers

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

  7. Program to create a circular queue

  8. Problem you will be analyzing a property of an algorithm whose classification is not known for all possible inputs

  9. PROGRAM TO DISPLAY MESSAGE USING COUT

  10. Program of time conversion using conversion functions

  11. Program to illustrate an example of Inheritance

  12. Program of constructor overloading

  13. Program that creats a 3D solid object using Translational Sweep Representatiom Method

  14. Program to illustrate unary operator(decrement operator) overloading without return type

  15. To parse a string using First and Follow algorithm and LL-1 parser

  16. Program to estimate the Integral value of a given function using Gussian Quadrature Rule

  17. write a class to represent a vector (a series of float values)

  18. Program to illustrate the use of call-by-refrence method in functions

  19. Program that reads a number and prints even if the number is even and prints odd if the number is odd.

  20. Program of Deterministic Finite Automation (DFA) for identifier, real number with optional Integer and Fractional Part

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