#include
#include
#include
const int maxstk=10;
int top;
int stack [maxstk];
push (int item);
pop();
display();
void main()
{
int ch, item;
do
{
cout<<"enter 1 for push \n"<<"enter 2 for pop"<<"\n enter 3 for exit \n";
cout <<"enter your choice";
cin>>ch;
switch (ch)
{
case 1:
cout <<"enter item to push";
cin>>item;
push (item);
break;
case 2:
pop();
break;
case 3:
exit (0);
break;
default:
cout<<"input is wrong \n";
break;
}
}
while(1);
}
push(int item)
{
if(top==maxstk)
{
cout<<"overflow\n";
return 0;
}
else
top=top+1;
stack[top]=item;
display();
}
pop()
{
if(top==0)
{
cout<<"underflow\n";
return 0;
}
else
top=top-1;
display();
}
display()
{
cout<<"Stack elements\n";
for(int i=1;i<=top;i++)
{
cout< }
}
a very unique and simple its very easy to understand no need to look up at algo great piece of work by programer
ReplyDeletehow is the logic of this?
ReplyDeletethere's error! how can i remove this.
ReplyDelete