go to previous page   go to home page   go to next page hear noise

Answer:

1. the loop body is only executed once.

count == 11 and increment == 2 will work, as will many others.

2. the loop body is executed twice.

count == 0 and increment == 7 will work, as will many others.

3. the loop body is not executed at all.

count == 100 and increment == 1 will work, as will many others.

4. the loop goes on forever.

count == 0 and increment == -1 will work, as will many others.

5. the loop body prints only "6" .

count == 6 and increment == 15 will work, as will many others.

Iteration

example loop

Each execution of a loop body is called an iteration. Sometimes the general concept of looping is also called iteration.

In a counting loop, each iteration changes an integer loop control variable by an integer amount. The amount of change can be positive or negative.


QUESTION 5:

Say that during a run of a program, the body of a loop was executed 5 times. How many times was the conditional part of the while statement evaluated?