Preview:
#include <iostream>
#include <stack>
using namespace std;



int main() {
    stack <int > s; // creation
    
    s.push(1); // putting vales 
    s.push(3);
    
    s.pop(); // removing one value 
    
    cout << "elemenst at top " << s.top() << endl;
    // printing top value 
    
    if(s.empty()) // checking 
    {
        cout << "stack is empty " << endl;
    }
    else
    {
         cout << "stack is not empty " << endl;
    }
    return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter