• Home
  • Textbooks
  • Engineering problem solving with C++
  • Control Structures: Repetition

Engineering problem solving with C++

Etter, Delores M;Ingber, Jeanine A

Chapter 4

Control Structures: Repetition - all with Video Answers

Educators


Chapter Questions

Problem 1

Indicate whether the following statements are true $(\mathrm{T})$ or false $(\mathrm{F})$.
A break statement is used to immediately exit from a loop.

Check back soon!
00:16

Problem 2

Indicate whether the following statements are true $(\mathrm{T})$ or false $(\mathrm{F})$.
The statement while(1) {} will generate an invalid operation.

Jeyasree R T
Jeyasree R T
Numerade Educator
01:15

Problem 3

Indicate whether the following statements are true $(\mathrm{T})$ or false $(\mathrm{F})$.
The do-while loop is always executed at least once.

Rukhmani Jain
Rukhmani Jain
Numerade Educator
01:51

Problem 4

Indicate whether the following statements are true $(\mathrm{T})$ or false $(\mathrm{F})$.
It is possible to omit either or all three of the expressions of a for loop.

Melissa Barry
Melissa Barry
Numerade Educator

Problem 5

Indicate whether the following statements are true $(\mathrm{T})$ or false $(\mathrm{F})$.
A sentinel-controlled loop is used for reading input data if the number of data values is known before the data are entered.

Check back soon!

Problem 6

Indicate whether the following statements are true $(\mathrm{T})$ or false $(\mathrm{F})$.
To debug a loop, we can use cout statements in the loop to provide memory snapshots of objects.

Check back soon!
01:28

Problem 7

Identify any syntax errors in the following statements. Assume that the objects have all been defined as integers.
for $(b=1, b=<25, b++)$

Ernest Castorena
Ernest Castorena
Numerade Educator
01:28

Problem 8

Identify any syntax errors in the following statements. Assume that the objects have all been defined as integers.
while $(k=1)$

Ernest Castorena
Ernest Castorena
Numerade Educator

Problem 9

Identify any syntax errors in the following statements. Assume that the objects have all been defined as integers.
9. $y=0$ :
for $(x=0, x<=20, x++)$
[ do $(\mathrm{y}<=10)$
i
cout $\ll x \cdot y \ll$ end 1 ;
y- :
]: while
$x++:]$ :

Check back soon!

Problem 10

What will the following statements accomplish?
int $x(5)$ :
while $(x<10)$
cout $<x<<" n$ : $x++$ :
int $x(5)$ :
while $(x<10)$
cout $<<<<" n: x++$ :
Which of the following statements are true?
(a) it will display a syntax error.
(b) it will print: 56789
(c) it will print: 5
(d) it will be an infinite loop.

Check back soon!
02:15

Problem 11

The statement for (:: $)$ would
(a) display a syntax error.
(b) generate an infinite loop.
(c) be an invalid operation.

Ernest Castorena
Ernest Castorena
Numerade Educator
07:44

Problem 12

How many times will the for statement for (int $k=5: k<97: k+=5$ ) be executed?
(a) 19
(b) 20
(c) 18

Samuel Goyette
Samuel Goyette
Numerade Educator
01:14

Problem 13

How many * signs will the following statements display?
for $(x=0: x<3: x++)$
for (int $\left.y=0 ; y<4 ; y^{++}\right)$cout $<<" * "$;
(a) 3
(b) 4
(c) 12
(d) none of the above.

Grant Castaneda
Grant Castaneda
Numerade Educator
04:24

Problem 14

What would you see on the screen if these statements were executed?
(a) $* * * * *$
(b) $* * * * * * * * *$
(c) $* * *$
(d) $* *$

Ernest Castorena
Ernest Castorena
Numerade Educator
01:29

Problem 15

What is the value of the variable star after the execution of these statements?
(a) 6
(b) 4
(c) 8
(d) 10

Vysakh M
Vysakh M
Numerade Educator
01:39

Problem 16

How many times is the statement cout $<<++1$; executed?
(a) 0
(b) 1
(c) 2
(d) 3

Aman Gupta
Aman Gupta
Numerade Educator
01:00

Problem 17

Generate a table of conversions from radians to degrees. Start the radian column at 0.0 , and increment by $\pi / 10$ until the radian amount is $2 \pi$.

Babita Kumari
Babita Kumari
Numerade Educator

Problem 18

Generate a table of conversions from degrees, to radians. The first line should contain the value for 0 degrees, and the last line should contain the value for 360 degrees. Allow the user to enter the increment to use between lines in the table.

Check back soon!
01:17

Problem 19

Generate a table of conversions from inches to centimeters. Start the inches column at 0.0 and increment by 0.5 in. The last line should contain the value $20.0 \mathrm{in}$. (Recall that $1 \mathrm{in} .=2.54 \mathrm{~cm}$.)

Kayleah Tsai
Kayleah Tsai
Numerade Educator
03:48

Problem 20

Generate a table of conversions from mph to $\mathrm{ft} / \mathrm{s}$. Start the mph column at 0 and increment by $5 \mathrm{mph}$. The last line should contain the value $65 \mathrm{mph}$. (Recall that $1 \mathrm{mi}=5,280 \mathrm{ft}$.)

Kelly Korek
Kelly Korek
Numerade Educator
03:17

Problem 21

Generate a table of conversions from $\mathrm{ft} / \mathrm{s}$ to mph. Start the $\mathrm{ft} / \mathrm{s}$ column at 0 and increment by $5 \mathrm{ft} / \mathrm{s}$. The last line should contain the value $100 \mathrm{ft} / \mathrm{s}$. (Recall that $1 \mathrm{mi}=5,280 \mathrm{ft}$.)

Amisha Tiwari
Amisha Tiwari
Numerade Educator
01:09

Problem 22

Generate a table of conversions from pesos to dollars. Start the pesos column at 5 pesos and increment by 5 pesos. Print 25 lines in the table.

Vishal Parmar
Vishal Parmar
Numerade Educator
07:19

Problem 23

Generate a table of conversions from yen to pesos. Start the yen column at $1 \mathrm{Y}$ and increment by 2 Y. Print 30 lines in the table.

RO
Reynald Oliveria
Numerade Educator
01:49

Problem 24

Generate a table of conversions from yen to South African rand. Start the yen column at $100 \mathrm{Y}$ and print 25 lines, with the final line containing the value $10,000 \mathrm{Y}$.

Mary Brese
Mary Brese
Numerade Educator
01:49

Problem 25

Generate a table of conversions from dollars to pesos, South African rand, and yen. Start the column with $\$ 1$ and increment by $\$ 1$. Print 50 lines in the table.

Mary Brese
Mary Brese
Numerade Educator
03:37

Problem 26

Write a program to generate a table of conversions from Fahrenheit to Celsius for values from 0 degrees $F$ to 100 degrees $F$. Print a line in the table for each 5 -degree change. Use a while loop in your solution.

WM
William Mead
Numerade Educator
03:37

Problem 27

Write a program to generate a table of conversions from Fahrenheit to Kelvin for values from 0 degrees $\mathrm{F}$ to 200 degrees $\mathrm{F}$. Allow the user to enter the increment in degrees Fahrenheit between lines. Use a do/while loop in your solution.

WM
William Mead
Numerade Educator
03:37

Problem 28

Write a program to generate a table of conversions from Celcius to Rankin. Allow the user to enter the starting temperature and increment between lines. Print 25 lines in the table. Use a for loop in your solution.

WM
William Mead
Numerade Educator
02:55

Problem 29

Assume that there are 14,000 acres total with 2,500 acres uncut and that the reforestation rate is 0.02 . Print a table showing the number of acres forested at the end of each year, for a total of 20 years.

Ashley Volpe
Ashley Volpe
Numerade Educator
02:39

Problem 30

Modify the program developed in problem 31 so that the user can enter the number of years to be used for the table.

Niamat Khuda
Niamat Khuda
Numerade Educator
03:58

Problem 31

Modify the program developed in problem 31 so that the user can enter a number of acres and the program will determine how many years are required for the number of acres to be completely reforested.

Harriet O'Brien
Harriet O'Brien
Numerade Educator

Problem 32

Rewrite program chapter 3 _1, developed in Chapter 3 , and use nested for loops.

Check back soon!

Problem 33

Modify program chapter 4 . 4 , developed in this chapter, by replacing the for loop with a do/while loop.

Check back soon!

Problem 34

Modify program chapter 4 . , developed in this chapter, by replacing the for loop with a while loop.

Check back soon!