You are on page 1of 2

#include<iostream.

h>
#include<conio.h>
int push(int[], int, int,int);
int pop(int[], int,int);
void main()
{int stack[5],top=-1,num,max=5;
//void push();
//void pop();
char ch='y';
while(ch=='y')
{cout<<"Enter the data";
cin>>num;
top=push(stack,max,num,top);
cout<<"Wanna continue";
cin>>ch;
}
cout<<"Pop Operation";
ch='y';
while(ch=='y')
{top=pop(stack,max,top);
//cout<<num;
cout<<"Wanna continue";
cin>>ch;
}
}

int push(int stack[],int max,int num,int top)


{if (top==max-1)
{cout<<"Overflow";
return -1;
}
top=top+1;
stack[top];
return top;
}
int pop(int stack[],int max,int top)
{
if (top==-1)
{cout<<"Underflow";
return -1;
}
cout<<stack[top];
top--;
return top;
}

You might also like