Chapter Questions
Indicate whether the following statements are true $(\mathrm{T})$ or false $(\mathrm{F})$.A break statement is used to immediately exit from a loop.
Indicate whether the following statements are true $(\mathrm{T})$ or false $(\mathrm{F})$.The statement while(1) {} will generate an invalid operation.
Indicate whether the following statements are true $(\mathrm{T})$ or false $(\mathrm{F})$.The do-while loop is always executed at least once.
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.
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.
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.
Identify any syntax errors in the following statements. Assume that the objects have all been defined as integers.for $(b=1, b=<25, b++)$
Identify any syntax errors in the following statements. Assume that the objects have all been defined as integers.while $(k=1)$
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)$icout $\ll x \cdot y \ll$ end 1 ;y- :]: while$x++:]$ :
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.
The statement for (:: $)$ would(a) display a syntax error.(b) generate an infinite loop.(c) be an invalid operation.
How many times will the for statement for (int $k=5: k<97: k+=5$ ) be executed?(a) 19(b) 20(c) 18
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.
What would you see on the screen if these statements were executed?(a) $* * * * *$(b) $* * * * * * * * *$(c) $* * *$(d) $* *$
What is the value of the variable star after the execution of these statements?(a) 6(b) 4(c) 8(d) 10
How many times is the statement cout $<<++1$; executed?(a) 0(b) 1(c) 2(d) 3
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$.
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.
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}$.)
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}$.)
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}$.)
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.
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.
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}$.
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.
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.
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.
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.
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.
Modify the program developed in problem 31 so that the user can enter the number of years to be used for the table.
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.
Rewrite program chapter 3 _1, developed in Chapter 3 , and use nested for loops.
Modify program chapter 4 . 4 , developed in this chapter, by replacing the for loop with a do/while loop.
Modify program chapter 4 . , developed in this chapter, by replacing the for loop with a while loop.