stack implementation

#include <iostream>
#include <stack>

int main() {
    // Step 1: Declare a stack
    std::stack<int> myStack;

    // Step 2: Push elements onto the stack
    myStack.push(10);
    myStack.push(20);
    myStack.push(30);

    // Step 3: Check if the stack is empty
    if (myStack.empty()) {
        std::cout << "Stack is empty." << std::endl;
    } else {
        std::cout << "Stack is not empty." << std::endl;
    }

    // Step 4: Access the top element of the stack
    std::cout << "Top element: " << myStack.top() << std::endl;

    // Step 5: Pop elements from the stack
    myStack.pop();

    // Step 6: Check the size of the stack
    std::cout << "Stack size: " << myStack.size() << std::endl;

    // Step 7: Pop remaining elements from the stack
    while (!myStack.empty()) {
        myStack.pop();
    }

    // Step 8: Check if the stack is empty after popping all elements
    if (myStack.empty()) {
        std::cout << "Stack is empty." << std::endl;
    } else {
        std::cout << "Stack is not empty." << std::endl;
    }

    return 0;
}