← Back to STL Containers
Question 480
Drain a Queue
Drain a Queue
Aqueue<int>namedqalready 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 withq.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
Sign in to use hintsTopics:
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.