#include<stdio.h>
#include<conio.h>
void main()
{
int stack[5],i,top,maxstk,
choise, data;
maxstk=4;top=-1;
printf("\n What do you want to do? PUSH/POP/Nothing(1/2/3)");
scanf("%d",&choise);
while((choise==1)||(choise==2))
{
if(choise==1)
{
if(top==maxstk)
{
printf("\n Overflow");
}
else
{
printf("\n Enter data:");
scanf("%d",& data);
top=top+1;
stack[top]=data;
}
}
else if(choise==2)
{
if(top<0)
printf("\n Overflow");
else
{
data=stack[top];
top=top-1;
}
}
else
break;
printf("\n Now the stack is:\n");
for(i=0;i<=top;i++)
printf("%d,",stack[i]);
printf("\n What do you want to do? PUSH/POP/Nothing(1/2/3)");
scanf("%d", & choise);
}
}