4. Loops Flashcards
(6 cards)
1
Q
Loop
A
- Program construct that repeatedly executes the loop’s statements (known as the loop body)
- while the loop’s expression is true; when false, execution proceeds past the loop.
2
Q
Iteration
A
Each time through a loop’s statements is called an iteration.
3
Q
While Loop
A
- Executes while the loop repeatedly executes the loop body while the loop’s expression evaluates to true
- Exits loop when condition is false
- When the number of iterations is not known
4
Q
For Loop
A
- Consisting of a loop variable initialization, a loop expression, and a loop variable update that typically describes iterating for a specific number of times.
- When the number of iterations is known
5
Q
Nested Loop
A
- A loop that appears in the body of another loop.
- Referred to as the inner loop and outer loop
6
Q
Do-while loop
A
- First executes the loop body’s statements, then checks the loop condition.
- When the loop should iterate at least once