Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an array based queue in C++ with the number of elements and elements ente

ID: 3759671 • Letter: C

Question

Create an array based queue in C++ with the number of elements and elements entered from the keyboard and prints them and then finds the minimum, maximum, average of the stack elements.

Could you just modify this code for me. I'm not sure how to take the user input in a queue:

#include <iostream>

#include <queue>

using namespace std;

int main()

{

queue<int> intQueue;

int number, i;

cout << "Enter some integers: "<<endl;

do

{

cin >> number;

intQueue.push(number);

} while (number);

cout << "The queue contains: ";

while (!intQueue.empty())

{

cout << " " << intQueue.front();

intQueue.pop();

}

}

Explanation / Answer

#include <iostream>
#include <queue>
using namespace std;
int main()
{
queue<int> intQueue;
int number, i;
cout << "Enter some integers: "<<endl;

do
{
cin >> number;
intQueue.push(number);
} while (number);
cout << "The queue contains: ";
while (!intQueue.empty())
{
cout << " " << intQueue.front();
intQueue.pop();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote