Repetition Statements (Looping)
- A control structure that allows the computer to execute one or more statements multiple times
- Pre-test loops execute zero or more times; the loop may never execute
- Post-test loops execute one or more times; the loop will always execute at least once
- Fixed repetition (count controlled) loops versus variable condition (event controlled) loops
- Each repetition is called an iteration
- The
for loop is common; it is a pre-test loop
for < a specific number of times> <perform an action>
while loop is also common; it is a pre-test loop
while <some condition is true> <perform an action>
do . . . while loop is less common; it is a post-test loop
do <perform an action> while <some condition is true>
Next slide
Back to Lesson 9 Index
Back to Outline