Repetition Flashcards

1
Q

for

A

use when you know how many times to repeat the loop
for index=expression
commands to be executed
end

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

while

A

used when you need to repeat a loop until a criterion is met
while expression
commands to be executed
end
if expression is true, the commands will be repeated until it becomes false; then the program will skip over the commands and execute first command after end
(find one condition that must be true after the loop, use the OPPOSITE of that condition for the loop expression)

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

break

A

used to terminate a loop prematurely; ends smallest enclosing for or while loop

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

continue

A

causes a detour of the program, skips to next pass

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

nested loop

A

complete for/while loop inside another for/while loop

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