Consider the following statements:
stackTypestack;queueType queue;int x;Suppose the input is:15 28 14 22 64 35 19 32 7 11 13 30 −999Show what is written by the following segment of code: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 Element = &“≪ stack.top ( ) ≪ end1;stack.pop ( );elsecout ≪ “Sorry, the stack is empty.” ≪ end1; break;case 2:queue.addQueue(x);break;case 3:if (!queue.isEmptyQueue ( )){cout ≪ “Queue Element = &” ≪ queue.front ( ) ≪ endl;queue.deleteQueue ( );}elsecout ≪ “Sorry, the queue is empty.” ≪ end1; break;} //end switchcin ≫ x;} //end whilecout ≪ “Stack Elements: “;while (!stack.isEmptyStack ( )){cout ≪ stack.top ( ) ≪ “ ”; stack.pop ( );}cout ≪ end1;cout ≪ “Queue Elements:”; while (!queue.isEmptyQueue ( )){cout ≪ queue.front() ≪ “ ”; queue.deleteQueue ( );}cout ≪ end1;
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.