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 read n integers and add them up and output the result

  2. Program to print a diamond

  3. Program of Boundary Fill (8 Connected Point).

  4. Program to help Umar in this task. Represent each city by one lowercase character. Thus, you can have at most 26 different cities to visit....

  5. Program to get possible prime numbers like number 6158 contains the substrings 6, 1, 5, 8, 61, 15, 58, 615, 158, and 6158.Find the largest substring..

  6. Program to show the use of Bitwise Operator Left Shift ( &lt;&lt; )

  7. Program of Deapth First Search Traversal ( DFS )

  8. Program that prints first 20 integers in reverse order (using while loop )

  9. Program that uses this DFA and validates whether an entered string is valid integer or not.

  10. Program to estimate the Differential value of a given function using Runge-Kutta Methods

  11. Program to draw an Ellipsoid using Parametric Equations

  12. Program to display numeric triangle for user given value

  13. Program to illustrate unary operator increment operator overloading with return type

  14. Program of maintaining banking account information system using inheritance

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

  16. Program to implement Add and Subtract function on Big Number Class

  17. Program of scaling about reference point

  18. Program to solve the Towers of Hanoi Problem (using Recursive Algorithm)

  19. Program that maintains telephone directory

  20. Program to sort that set of strings in ascending and descending order of their weights. The sorted output is to be displayed on the screen

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