Implement Push, Pop Operation of A Stack Using Arrays
Implement Push, Pop Operation of A Stack Using Arrays
#include<iostream.h>
#include<conio.h>
class Stack{
public:
int stack[MAX],top,n;
Stack(){
top=-1;
n=0;
void size(){
cin>>n;
top++;
stack[top]=data;
void pop(){
int item;
if(top==-1){
cout<<"\nStack is empty...";
else{
item=stack[top];
top--;
cout<<"\nThe Deleted Item is :"<<item;
};
void main(){
Stack s;
int data,ch;
char ex;
clrscr();
s.size();
do{
cin>>ch;
switch(ch)
case 1:
if(s.top==s.n-1)
cout<<"\nStack Overflow...";
else
cin>>data;
s.push(data);
}
break;
case 2:
s.pop();
break;
case 3:
cin>>ex;
break;
default:
cout<<"Choice is Invalid...";
}while((ex!='Y')&&(ex!='y'));
getch();
}
OUTPUT