| 3 | using namespace std; |
| 4 | |
| 5 | int main() |
| 6 | { |
| 7 | stack<int>s; |
| 8 | //add elements |
| 9 | s.push(4); |
| 10 | s.push(5); |
| 11 | s.push(6); |
| 12 | s.push(7); |
| 13 | |
| 14 | //remove elements from last |
| 15 | s.pop(); |
| 16 | |
| 17 | //display the top most elements |
| 18 | cout<<s.top()<<endl; |
| 19 | |
| 20 | //display the size of the stack |
| 21 | cout<<s.size()<<endl; |
| 22 | |
| 23 | //checking if stack is empty or not |
| 24 | if (s.empty()) |
| 25 | { |
| 26 | cout<<"Yes Empty"<<endl; |
| 27 | } |
| 28 | else |
| 29 | { |
| 30 | cout<<"No Not Empty"<<endl; |
| 31 | } |
| 32 | |
| 33 | return 0; |
| 34 | } |