pop and push in stack in c++ code example
Example: push pop code in c++
#include
using namespace std;
#define Max 100
class stack{
public:
int top;
int size;
int *s;
int stack[Max];
void push()
{
int value;
if(top==size-1)
{
cout<<"overflow";
}
else
{
cout<<"Enter value to push \n";
cin>>value;
top++;
stack[top]=value;
}
}
int pop()
{
if(top==-1)
{
cout<<"Underflow";
}
else
{
cout<<"Deleted value is \n"<=0;i--)
{
cout<>st.size;
st.s=new int[st.size];
st.top=-1;
int ch;
while(st.size!=0)
{
cout<>ch;
switch(ch)
{
case 1:
st.push();
break;
case 2:
st.pop();
break;
case 3:
st.display();
break;
case 4:
exit(0);
default:cout<<"\n Choose correct option";
}
}
return 0;
}