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 draw a line using Bresenhams Line Algorithm (BLA)

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

  3. Simple Inventory Program

  4. Program to create a queue using static memory allocation

  5. Matrix Addition Program

  6. Program that takes short date from a user and displays medium date

  7. Program to estimate the value of Fourth Derivative of the function at the given points from the given data using Central Difference Formula of order 4

  8. Program to coumputes and displays the factorial of the given number ( using Recursive Algorithm )

  9. Program to show the use of Bitwise Operator Right Shift ( &gt;&gt; )

  10. Program to perform sorting of linklist

  11. Program to estimate the value of Third Derivative of the function at the given points from the given data using Central Difference Formula of order 2

  12. Program that reads marks obtained by a student in a test of 100 marks and print pass if marks are greater than or equal to 50

  13. Program to translate integer numbers given in words into numeric representation

  14. Program to multiply two matrices

  15. Program to draw a circle using Trigonometric Method

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

  17. Program to illustrate classes without using inline functions

  18. Program to show the Urdu Alphabets using Stroke Method

  19. Program to show the projection of 3D objects using Orthographics Projection Parallel onto xy-plane

  20. Program to illustrate the use of parameterless function

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