Question: (You can use the queue operation in the sample file on blackboard or from the STL library to perform operations such as enqueue, dequeue, isEmpty,
(You can use the queue operation in the sample file on blackboard or from the STL library to perform operations such as enqueue, dequeue, isEmpty, isFull... etc).
A queue named queue1 has 10 elements. Write a C++ function to accept numbers from the keyboard. If a number is positive, it is enqueued in queue1. If it is negative, one of the existing numbers in queue1 is dequeued. After each enqueue or deque operation, the elements in the queue are printed. Also, the program terminates if the queue becomes empty?
Output: print the following to both console:
The initial content of the queue
The content of queue after performing each enqueue or dequeue operation and the reason why:
Example:
If the queue has the number 3, 8, 2,
When entering 7 from keyboard, it should display.
7 is positive number after enqueuing, queue1 content is: 3, 8, 2, and 7
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
