Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Show what is written by the following segments of code, given that item1, item2, and item3 are int variables. a. QueType queue; item1 = 1;

Show what is written by the following segments of code, given that item1, item2, and item3 are int variables.

a.

QueType queue;

item1 = 1;

item2 = 0;

item3 = 4;

queue.Enqueue(item2);

queue.Enqueue(item1);

queue.Enqueue(item1 + item3);

queue.Dequeue(item2);

queue.Enqueue(item3*item3);

queue.Enqueue(item2);

queue.Enqueue(3);

queue.Dequeue(item1);

cout << item1 << endl << item2 << endl << item3

<< endl;

while (!queue.IsEmpty())

{

queue.Dequeue(item1);

cout << item1 << endl;

}

b.

QueType queue;

item1 = 4;

item3 = 0;

item2 = item1 + 1;

queue.Enqueue(item2);

queue.Enqueue(item2 + 1);

queue.Enqueue(item1);

queue.Dequeue(item2);

item1 = item2 + 1;

queue.Enqueue(item1);

queue.Enqueue(item3);

while (!queue.IsEmpty())

{

queue.Dequeue(item3);

cout << item3 << endl;

}

cout << item1 << endl << item2 << endl << item3 << endl;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is the cerebrum?

Answered: 1 week ago