//SEPTEMBER 10, 2002
#include <iostream.h>
void push(int mystack[], int&mytop, int item){
mystack[mytop]=item;
mytop=mytop+1; } //PUSH
int pop(int mystack[], int&mytop){
mytop=mytop-1;
int item=mystack[mytop];
return item;} //POP
int isempty(int mytop){
if(mytop==0)
return 1;
else return 0;} //ISEMPTY
int isfull(int mytop, const int maxstacksize){
if(mytop==maxstacksize) return 1;
else return 0;} //ISFULL
void main(){
const int
maxstacksize=5;
int mystack[maxstacksize]; int mytop,x,option;
mytop=0; //STACK TOP INITILIZATION
do{ cout<<"select one of the
following options: "<<endl;
cout<<"1-push 2-pop 3-isempty
4-isfull 5-quit: ";
cin>>option;
switch(option){
case 1: if(isfull(mytop,maxstacksize))
cout<<"you can't push"
<<endl;
else{
cout<<"enter the number that will be pushed: ";
cin >>x;
push(mystack,mytop,x);} //ELSE
break;
case
2: if(isempty(mytop))
cout<<"you can't pop"
<<endl;
else
{ cout<<"the number popped is: "<<pop(mystack,mytop);
cout <<endl;} //ELSE
break;
case
3: if(isempty(mytop)==1)
cout<<"stack empty. "
<<endl;
else
cout<<"stack is not empty." <<endl;
break;
case
4: if(isfull(mytop,maxstacksize)==1)
cout<<"stack full."
<<endl;
else
cout<<"stack is not full." <<endl;
break;
case
5: cout<<"thank you for using our menu!"<<endl;
break;
default:cout<<"enter
correct options"<<endl;
} //SWITCH
}
while (option!=5);
} //MAIN