CJCoding With Joseph
15free / daySign inCreate account

Drain a Stack

A stack<int> named s already holds 1, 2, 3 (3 is on top). Write a loop that keeps printing the top element and popping it until the stack is empty. Print each value followed by a space; the final newline is already printed for you.

Print exactly what is shown in Expected Output.

Expected Output:

3 2 1

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
STL ContainersStacks
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.