1#include<iostream>
2using namespace std;
3#define Max 100
4class stack{
5 public:
6 int top;
7 int size;
8 int *s;
9 int stack[Max];
10
11 void push()
12 {
13 int value;
14 if(top==size-1)
15 {
16 cout<<"overflow";
17 }
18 else
19 {
20 cout<<"Enter value to push \n";
21 cin>>value;
22 top++;
23 stack[top]=value;
24 }
25 }
26 int pop()
27 {
28 if(top==-1)
29 {
30 cout<<"Underflow";
31 }
32 else
33 {
34 cout<<"Deleted value is \n"<<stack[top];
35 top--;
36 }
37 }
38 void display()
39 {
40 int i;
41 for(i=top;i>=0;i--)
42 {
43 cout<<stack[i]<<endl;
44 }
45 }
46};
47int main()
48{
49 stack st;
50 cout<<"Enter the size of the stack";
51 cin>>st.size;
52 st.s=new int[st.size];
53 st.top=-1;
54 int ch;
55 while(st.size!=0)
56 {
57 cout<<endl<<" ##### STACK MENU ##### "<<endl;
58 cout<<"1. PUSH OPERATION \n2. POP OPERATION \n3. DISPLAY \n4.Exit \n";
59 cin>>ch;
60 switch(ch)
61 {
62 case 1:
63 st.push();
64 break;
65 case 2:
66 st.pop();
67 break;
68 case 3:
69 st.display();
70 break;
71 case 4:
72 exit(0);
73
74 default:cout<<"\n Choose correct option";
75 }
76}
77return 0;
78}