Showing posts with label stack using stl. Show all posts
Showing posts with label stack using stl. Show all posts

Tuesday, November 3, 2020

Stack Using STL : CODE | C++


// stack using STL


#include<stack>

#include<iostream>


using namespace std;

int main(){

stack<int>s;

// push

s.push(2);

s.push(4);

s.push(5);

s.push(7);


// 2 4 5 7


//pop

s.pop();  // removed 7


//top

cout<<" top = "<<s.top();  // 5 


// is empty

if(s.empty())cout<<"\nyes";

else cout<<"\nNO";


// size

cout<<" \nsize = "<<s.size();  // 3

}