8) What is the output of the following statements: stack s; int x-4,y-e; s.push(7); s.push(x); s.push(x+5);...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
8) What is the output of the following statements: stack<int> s; int x-4,y-e; s.push(7); s.push(x); s.push(x+5); y=s.top(); s.pop(); s.push(x+y); s.push(y-2); s.push(3); x = s.top(); s.pop(); cout<<"x= "<<x<<endl; cout<<"y="<<y<<endl; while (Is.empty()) { cout<<s.top() <<endl; s.pop(); int x,y; x-4;y-5; q.push(x); q.push(y); x- q. front (); X= } 9) What is the output of the following statements: queuecint> q; q.pop(); q.push(x+5); q.push(16); q.push(x); q.push(y-3); cout<<"Queue Elements: "; while (Iq.empty()) { cout<<q. front ()<<" "; q.pop(); } ده کل cout<<endl; 7 8) What is the output of the following statements: stack<int> s; int x-4,y-e; s.push(7); s.push(x); s.push(x+5); y=s.top(); s.pop(); s.push(x+y); s.push(y-2); s.push(3); x = s.top(); s.pop(); cout<<"x= "<<x<<endl; cout<<"y="<<y<<endl; while (Is.empty()) { cout<<s.top() <<endl; s.pop(); int x,y; x-4;y-5; q.push(x); q.push(y); x- q. front (); X= } 9) What is the output of the following statements: queuecint> q; q.pop(); q.push(x+5); q.push(16); q.push(x); q.push(y-3); cout<<"Queue Elements: "; while (Iq.empty()) { cout<<q. front ()<<" "; q.pop(); } ده کل cout<<endl; 7
Expert Answer:
Answer rating: 100% (QA)
8 creates an empty stack s and initialize x to 4 and y to 0 stack s int x4 y0 spush7 inserts 7 at to... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these computer network questions
-
Making a java program that's an Integer calculator. You will provide an infix string as input into the Calculator program. The Calculator program will display the postfix notation and evaluate the...
-
Three partners. Ankamah, Kofi and David share profit and losses in the ratio 5: 3:2 for the year ending 31/12/2016. The profit generated from either business is $600,000. Partners' contributions are...
-
Helium gas in an ideal Otto cycle is compressed from 20C and 2.5 to 0.25 L, and its temperature increases by an additional 700C during the heat addition process. The temperature of helium before the...
-
Identify the major issues relating to e-tailing.
-
Refer to the information from QS 21-18. Compute the variable overhead spending variance and the variable overhead efficiency variance and classify each as favorable or unfavorable. Data From QS 21-18...
-
Stahl Inc. produces three separate products from a common process costing $100,000. Each of the products can be sold at the split-off point or can be processed further and then sold for a higher...
-
Jessa owns a house and lot on 9th Avenue. She sells the house to the Hartley family, who wish to have a conveyance from her that says, to Harriet Hartley for life, remainder to her son, Alexander...
-
Maria has AGI of $100,000. She donated stock to University worth $50,000, which she had a basis of $40,000. She held the stock for three months before making the donation. What are the tax...
-
What are the Types of Process and Thread in Operating System? Explain All. Furthermore, Explain Process Scheduling with the help of valid diagram in respect to Linux OS.
-
Revenue-sharing contracts usually result in the supply chain producing to consumer demand. higher cost of returns. lower retailer profit. lower retailer effort.
-
Walmart has worked to convert ________ at its stores from a cost to a profit generator. energy usage waste generation water consumption packaging
-
Price has traditionally been the only dimension that suppliers have been compared on during the process of supplier scoring and assessment. sourcing. procurement. supplier selection.
-
A third party may increase the supply chain surplus by aggregating warehousing needs over several firms. This is called capacity aggregation. inventory aggregation. warehouse aggregation....
-
Good design collaboration for manufacturability and supply chain can increase required inventories. reduce product cost. increase transportation cost. decrease manufacturability.
-
Our modern and tech-focused world allows us to fall into a sedentary lifestyle easily. We are often plugged into our computers at work, spend time on devices at home, and have automated home systems...
-
A heat engine has a heat input of 3 Ã 104 Btu/h and a thermal efficiency of 40 percent. Calculate the power it will produce, in hp. Source 3 x 10 Btu/h 40% HE Sink
-
Write a piece of code that computes the average String length of the elements of an array of Strings . For example, if the array contains {"belt", "hat", "jelly", "bubble gum"}, the average length is...
-
Javas type int has a limit on how large an integer it can store. This limit can be circumvented by representing an integer as an array of digits. Write an interactive program that adds two integers...
-
Use the compareTo method to write code that reads two names from the console and prints the one that comes first in alphabetical order. For example, the programs output might look like the following:...
-
Reconsider Problem 18. Management has decided that the $5 million raised through stock should be split between common stock and preferred stock. Common stock will be used to raise $3,000,000 and...
-
Repeat Problem 23 assuming that the stock price is growing at 3 percent per year. Data from problem 23 Lahoma Enterprises, Inc., needs $15 million to finance a major product development. The project...
-
Repeat Problem 23 assuming the stock offering will be preferred stock rather than common stock. The preferred stock will sell for $120/share, pay a $9 annual dividend, and have a cost of selling of...
Study smarter with the SolutionInn App