#include<iostream.h>
#include<conio.h>
#include<process.h>
const int max=5;
class stack
 {
  int s[max];
  int top;
  int temp;
  public:
  stack (int j,int p){top=j;temp=p;}
  void push(int item);
  void pop();
  void display();
 };
  void stack::push(int item)
   {
    if(top<4)
     {
      top++;
      s[top]=item;
     }
    else
     {
      cout<<"\nStack is full!";
     }
  }
  void stack::pop()
   {
    if(top>-1)
     {
      cout<<"\nThe popped item is "<<s[top];
      top--;
     }
    else
     {
      cout<<"\nStack is empty!";
     }
  }
 void stack::display()
  {
   temp=top;
   if(temp==-1)
    {
     cout<<"\nStack is empty!" ;
    }
    else
     {
      while(temp>=0)
       {
	cout<<"\n"<<s[temp];
	temp--;
       }
      }
  }
 void main()
  {
   clrscr();
   stack x(-1,-1);
   for(;;)
    {
     int ch,item;
     cout<<"\nEnter->\n1:push 2:pop 3:display 4:exit:\t";
     cin>>ch;
     switch(ch)
      {
       case 1: cout<<"\nEnter the items:\t";
	       cin>>item;
	       x.push(item);
	       break;
       case 2: x.pop();
	       break;
       case 3: x.display();
	       break;
       case 4: exit(0);
	       break;
     }
   }
 }

Using stack without dynamic mem allocation is like... ummm... using stack without dynamic mem allocation (LOL)

The answer is most assuredly forty-two.

Well what else would it be, although i don't feel that this is important enought to be given an answer equivelant to the meaning of life!

but seriously, whats the question / problem?

Chris

This article has been dead for over six months. Start a new discussion instead.