Explore BrainMass
Share

output from the following sequence of stack operations

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? (please include the code and .exe)

See attached file.

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();
intStack.push(22);
while (!intStack.empty())
{ y = intStack.top();
intStack.pop();
cout <<Y<<" ";
}
cout <<x<<end1;

© BrainMass Inc. brainmass.com March 21, 2019, 4:23 pm ad1c9bdddf
https://brainmass.com/computer-science/cpp/output-following-sequence-stack-operations-183977

Attachments

Solution Summary

It finds the output from the following sequence of stack operations.

$2.19