#include
#include
class stack
{
private:
int stack_array[10];
int top;
public:
stack()
{
top = -1;
}
int full()
{
if(top == 9)
return(1);
else
return(0);
}
int empty()
{
if(top == -1)
return(1);
else
return(0);
}
void push(int passed_value)
{
top++;
stack_array[top]=passed_value;
cout<
{
cout<
switch(choice)
{
case 1:
if(mystack.full())
{
cout<<"\nStack Full"; break; } cout<<"Enter an element: "; cin>>choice;
mystack.push(choice);
getch();clrscr();
break;
case 2:
if(mystack.empty())
{
cout<<"\nStack Empty\n";
break;
}
mystack.pop();
getch();clrscr();
break;
case 3:
mystack.display();
getch();clrscr();
break;
case 4:
exit(0);
break;
default:
cout<<"\nEnter Correct Choice:";
}
}
}
No comments:
Post a Comment