Chapter Questions
Describe what this statement does:print "user name $="$ userName
Provide an appropriate variable name for a variable that holds the total number of students.
Write a line of pseudocode that tells the computer to assign distance divided by time into a speed variable.
Write a line of pseudocode that tells the computer to put a user entry into a variable called height.
What are the three types of control flow described in this chapter?
Looping is appropriate whenever the next thing done is something previously done. (T / F)
Consider the following pseudocode: if it is night, set speedLimit to 55; otherwise, set speedLimit to 65. Suppose the value of the variable, night, is “false.” After this code runs, what should be the value of thevariable, speedLimit?
The above pseudocode does not have the exact form suggested in the text. Is that OK?
Draw a flowchart that implements this logic: If the temperature is greater than $10^{\circ} \mathrm{C}$ and it's not raining, print "walk." Otherwise, print "drive."
Provide a solution to the previous problem in the form of pseudocode.
Where is a while loop's terminating decision made?
When a while loop terminates, what executes next?
Is it possible for a while loop to have an infinite number of iterations?
Is it possible for a while loop to have zero iterations?
What are the three loop termination techniques described in this chapter?
A sentinel value is used to do which of the following?a) Specify the first value printed.b) Print an error message.c) Signal the end of input.
How does the form of pseudocode we use in most of this chapter differentiate an inner loop from an outer loop?
Which of the following is true?a) Tracing shows sequence of execution.b) Tracing helps you debug a program.c) Tracing highlights errors in loop initialization and termination.d) All of the above.
Trace the following Bowling Score algorithm (taken from Section 2.9). Use the setup shown below the algorithm.1 set totalscore to 02 set count to 03 print "Enter score $(-1 \text { to quit): } "$4 input score5 while score is not equal to -16 set totalscore to totalscore + score7 set count to count +1$8 \quad$ print "Enter score $(-1$ to quit): "9 input score10 set avg to totalscore / count11 print "Average score is " avgTrace setup:input941041141