C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 5.1, Problem 5E

(For review) a. What’s the difference between a pretest and posttest loop?

b. If the condition being tested in a pretest loop is false, how many times are statements in the loop executed?

c. If the condition being tested in a posttest loop is false, how many times are statements in the loop executed?

Blurred answer
Students have asked these similar questions
(SQL) Alter the program segment that generates n random numbers between 1and n. The new program too should generate numbers between 1 and n. Ifnumber being generated is equal to n/2 the control should terminate theloop. Otherwise, a new number between 1 and n should be generated. (thisloop should repeat maximum of 1000 times). When the program exits fromthe loop, if n/2 is not generated, it should display “could NOT generate”. If n/2is generated, it should display “could generate on the xth try”.
(Removing break and continue ) A criticism of the break statement and the continue statement is that each isunstructured. Actually, these statements can always be replaced by structured statements, although doing so can beawkward. Describe in general how you’d remove any break statement from a loop in a program and replace it with some structured equivalent. [Hint: The break statement exits a loop from the body of the loop. The other way to exit is by failing the loop-continuation test. Consider using in the loop-continuation test a second test that indicates “early exit because of a ‘break’ condition.”] Use the technique you develop here to remove thebreak statement from the application.
(Apartment problem) A real estate office handles, say, 50 apartment units. When the rent is, say, $600 per month, all the units are occupied. However, for each, say, $40 increase in rent, one unit becomes vacant. Moreover, each occupied unit requires an average of $27 per month for maintenance. How many units should be rented to maximize the profit? Instructions Write a program that prompts the user to enter: The total number of units. The rent to occupy all the units. Amount to maintain a rented unit. The increase in rent that results in a vacant unit. The program then outputs: The number of units to be rented to maximize the profit The maximum profit Since your program handles currency, make sure to use a data type that can store decimals with a decimal precision of 2.

Chapter 5 Solutions

C++ for Engineers and Scientists

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Control Structures - while loop - do-while loop - for loop - Goto - break - continue statements; Author: EzEd Channel;https://www.youtube.com/watch?v=21l11_9Osd0;License: Standard YouTube License, CC-BY