|
Say that during a run of a program,
the body of a loop was exectued 5 times.
How many times was the conditional part of the A good answer might be:Six times. For the loop body to have executed five times, the condition had to evaluate to true five times. Then the condition was evaluated one more time, this time yielding false. |
Decrementing the Loop Control VariableThe loop control variable in a counting loop can be changed by a negative value. Here is a program fragment that decrements the loop control variable at the bottom of each iteration:
Here is what the program will print:
Here is what happens, step-by-tedious-step:count is: 2 count is: 1 count is: 0 Done counting down.
|
QUESTION 6:Is it possible to count down by an amount other than one? Click Here after you have answered the question |