CJCoding With Joseph
15free / daySign inCreate account

Drain a Queue

A queue<int> named q already holds 1, 2, 3 (1 is at the front).

Write a loop that runs while the queue is not empty. On each pass print the front value followed by a single space, then remove it with q.pop(). The newline after the loop is already written for you - do not add another one.

(A trailing space after the 3 is fine.)

Expected Output:

1 2 3

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

Hints3 available
Topics:
STL ContainersQueues
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.