Repetition Structures Flashcards
What is a repetition structure in programming?
A statement or set of statements executed repeatedly.
Why are repetition structures better than repeating sequences of statements?
They simplify the code and reduce redundancy.
What is a loop?
A structure used to repeat a statement or set of statements.
What are the two types of loops in repetition structures?
Condition-controlled and count-controlled loops.
How does a condition-controlled loop work?
Repeats as long as a true/false condition is satisfied.
How does a count-controlled loop work?
Repeats a specific number of times.
What are While and Do-While loops?
Loops that repeat as long as a condition is true.
What is a Do-Until loop?
A loop that repeats until a condition becomes true.
What are the two parts of a While loop?
A condition tested for true/false and the body of the loop with statements to execute.
What is an iteration?
Execution of a loop’s body.
What makes a While loop a pretest loop?
It tests its condition before executing the loop body.
What causes an infinite loop?
Failing to make the test condition false within the loop.
How is a Do-While loop different from a While loop?
It performs at least one iteration before testing its condition.
What is a count-controlled loop’s counter variable?
A variable used to track the number of iterations.
What are the three actions for a counter variable in a For loop?
Initialize, test against a maximum value, and increment.