Explore BrainMass

Explore BrainMass

    stack operations in C++

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    What is the output from the following sequence of stack operations?

    stack<int> intStack;
    int x, y = 3;

    intStack.push(8);
    intStack.push(9);
    intStack.push(y);
    x = intStack.top();
    intStack.pop();
    intStack.push(18);
    x = intStack.top();
    intStack.pop();
    intStackpush(22);
    while (!intStack.empty())
    { y = intStack.top();
    intStack.pop();
    cout << y << " ";
    }
    cout << x << endl;

    Please provide a complete program if it makes sense.

    © BrainMass Inc. brainmass.com March 4, 2021, 7:56 pm ad1c9bdddf
    https://brainmass.com/computer-science/cpp/data-structures-using-stl-133453

    Solution Summary

    It finds the output from the sequence of stack operations. The response was rated '5/5' by the student who posted the question originally.

    $2.49

    ADVERTISEMENT