loops Flashcards

1
Q

The while loop

A

The while loop is a pretest loop. It is ideal in situations where you do
not want the loop to iterate if the condition is false from the beginning. It is also ideal
if you want to use a sentinel value to terminate the loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The do-while loop

A

The do-while loop is a posttest loop. It is ideal in situations where
you always want the loop to iterate at least once.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The for loop

A

The for loop is a pretest loop that has built-in expressions for initializing, testing, and updating. These expressions make it very convenient to use a loop
control variable as a counter. The for loop is ideal in situations where the exact number of iterations is known.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly