Show what is output by the following segment of


Consider the following statements:

stackType stack;
queueType queue;
int x;

Suppose the input is:
15 28 14 22 64 35 19 32 7 11 13 30 -999

Show what is output by the following segment of code.

stack.initializeStack();
queue.initializeQueue();
stack.push(0);
queue.addQueue(0);
cin>>x;

while(x != -999)
{
switch(x % 4)
{
case 0: stack.push(x);
break;
case 1: if(!stack.isEmptyStack())
{
cout<<"Stack Elment = "<stack.pop();
}
else
cout<<"Sorry, the stack is empty."<break;
case 2: queue.addQueue(x);
break;
case 3: if(!queue.isEmptyQueue())
{
cout<<"Queue Element = "<queue.deleteQueue();
}
else
cout<<"Sorry, the queue is empty."<break;
}//end switch

cin>>x;
}//end while

cout<<"Stack Elements: ";
while(!stack.isEmptyStack())
{
cout<stack.pop();
}

cout<cout<<"Queue Elements: ";
while(!queue.isEmptyQueue();
{
cout<queue.deleteQueue();
}
cout<

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Show what is output by the following segment of
Reference No:- TGS01247432

Now Priced at $20 (50% Discount)

Recommended (90%)

Rated (4.3/5)