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

  Implement a simple calculator program

Implement a simple calculator

  Find the pairs in any given matrix

write a c program which will find the pairs in any given matrix, whose sum of pairs are 10.

  Write a function called distance

Write a function called distance that takes two Points as arguments and returns the distance between them.

  Using the following program as a guide

Using the following program as a guide, write a program reads in 2 scores in the main function.. Calls a function that will triple each number. In the function and the print the result in the main function.

  Time conversion

Write a C++ program that takes an Eastern standard time in hours, minutes, and seconds,and prints it out in Central time, Mountain time, or Pacific time.

  Write a program to create 100 real random numbers

Write a program to create 100 real random numbers and store it into a 1-D array.

  C++ programs that compute the agreement for two vectors

In this assignment, you write C++ programs that compute the agreement for two given vectors (see Calculation 1 above). In these programs, in vectors A and B only nonzero elements (elements that are 1) are stored. We give you a function that gen..

  How to spot if a character is a lower case letter or not

You must be finding out how to convert a letter to upper case. I am having difficulty with this program because I do not know where to start with.

  Program solves the n-queens problem

you will write a program that solves the N-Queens problem by the backtracking method. The pseudocode for the solution is on the last page. Your program should run in standard Java, either as an application or an applet.

  Write a computer program to prepare a linear support vector

write a computer program to prepare a linear support vector machine svm. prepare a report and deliver the report

  Create a template class

Create a template class, SVector, that implements a constructor

  Extension of a filename

Modify your earlier program that found the extension of a filename. This time your program will identify a file name that is no longer that 12 characters and has one of five extensions that you specify (eg: .doc. .py, .html, .txt, .ps).

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