You are on page 1of 2

#include<iostream> using namespace std; int stack[5]; int chk=0; int size=5; bool check_empty(){ if(chk==NULL) return false;

else return true; } bool check_full(){ if(chk==size) return false; else return true; } void push(int n){ if(check_full()){ chk=chk+1; stack[chk]=n; } else { cout<<"Stack is full"<<endl; } } void pop(){ int value; if(check_empty()){ value=stack[chk]; chk=chk-1; cout<<value<<endl; } else{ cout<<"Stack is empty"<<endl; } } void main(){ int n,m,c=0; cout<<"Press 1 for push "<<endl; cout<<"Press 2 for pop "<<endl; cout<<"Press 3 for exit "<<endl; while(n!=3){ cout<<"###############Enter option in numbers##########"<<endl; cin>>n; if(n==1){ cout<<"Enter Value:";

cin>>m; push(m); c++; } else if(n==2){ pop(); } } }

You might also like