Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- #define Max_Size 100
- int A[Max_Size];
- int top=0;
- void push(int item)
- {
- if(top<Max_Size){
- A[top]=item;
- top++;
- }
- else cout<<"Stack is Empty"<<endl;
- }
- int pop()
- {
- if(top==0) cout<<"Stack is Full!!"<<endl;
- else
- {
- return A[--top];
- }
- }
- int main()
- {
- push(1);
- push(2);
- push(3);
- for (int i=0; i<top; i++) cout<<A[i]<<" ";
- cout<<endl;
- for (int i=0; i<2; i++)
- cout<<pop()<<" ";
- cout<<endl;
- for (int i=0; i<top; i++) cout<<A[i]<<" ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement