Show what is output by the following segment of code.

Assignment Help C/C++ Programming
Reference no: EM13938117

Consider the following statements:

stackType<int> stack;
queueType<int> 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.top()<<endl;
stack.pop();
}
else
cout<<"Sorry, the stack is empty."<<endl;
break;
case 2: queue.addQueue(x);
break;
case 3: if(!queue.isEmptyQueue())
{
cout<<"Queue Element = "<<queue.front()<<endl;
queue.deleteQueue();
}
else
cout<<"Sorry, the queue is empty."<<endl;
break;
}//end switch

cin>>x;
}//end while

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

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

Reference no: EM13938117

Questions Cloud

Calculate metrics influence behavior of operations team : Decisions about which business metrics to track and how to calculate those metrics influence the behavior of operations teams. One criteria we're interested in tracking is how many emailed replies (touches) it takes for support agents to resolve a..
Estimate impact on profit that result from dropping conway : Estimate the impact on profit that would result from dropping Conway. Explain why Petoskey should keep or drop Conway.
Illustrate and describe the angiosperm life cycle : List all of the information that should be recorded in the field notebook for any plant collected in the field and intended to become a herbarium specimen.
Describe the primary characteristics that all plants share : Plants originated in the water, then moved to land. In order to do this, plants had to evolve a number of important structures that enabled their survival on land. Describe the structural changes that had to happen to support this move and discuss..
Show what is output by the following segment of code. : Show what is output by the following segment of code.
Did the introduction develop the hypotheses logically : The hypothesis that was being tested was about the anti-predation behaviour exhibited by the while-tailed deer and how the response is affected in the presence of the predator - Did the introduction develop the hypotheses logically
How does this reflect the biodiversity of life over time : Look at plants and animals. Select a plant and an animal and see how it evolved up the Tree of Life from the beginning of time to the present. How did this species change over time? How did it start out and how did it evolve.
Business and functional level strategy : Assess the core areas of corporate, business and functional level strategy relevant to the international hospitality industry.
What is effective cost of borrowing in this case : Your firm has an average collection period of 26 days. Current practice is to factor all receivables immediately at a discount of 1.6 percent. What is the effective cost of borrowing in this case?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd