D278 section 4 Question and answers correctly solved
2025/2026
1. loop is 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. iteration true; when false, execution proceeds past the loop.
3. Common error is to use the opposite loop expression than desired, like using x == 0
in loops rather than x
!= 0. Programmers should remember that the expression describes
when the loop should iterate, not when the loop should exit.
4. infinite loop is a loop that never stops iterating. A common error is to accidentally
create an infinite loop, often by forgetting to update a variable in the body,
or by creating a loop expression whose evaluation to false isn't always
reachable.
5. sentinel value is a special value indicating the end of a list, such as a list of positive
integers ending with 0, as in 10 1 6 3 0.
6. while loop is a loop that repeatedly executes the loop body while the loop's
expression
evaluates to true
7. for loop is a loop consisting of a loop variable initialization, a loop expression,
and a loop variable update that typically describes iterating for a
specific number of times.
8. for Number of iterations is computable before the loop, like iterating N times.
9. while Number of iterations is not (easily) computable before the loop, like iterating
until the input is 'q'.
10. nested loop is a loop that appears in the body of another loop. The nested loops are
1/
5
, D278 section 4 Question and answers correctly solved
2025/2026
commonly referred to as the inner loop and outer loop.
11. while loop A while loop repeatedly executes the loop body while the loop's
expression evalu- ates to true.
2/
5
2025/2026
1. loop is 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. iteration true; when false, execution proceeds past the loop.
3. Common error is to use the opposite loop expression than desired, like using x == 0
in loops rather than x
!= 0. Programmers should remember that the expression describes
when the loop should iterate, not when the loop should exit.
4. infinite loop is a loop that never stops iterating. A common error is to accidentally
create an infinite loop, often by forgetting to update a variable in the body,
or by creating a loop expression whose evaluation to false isn't always
reachable.
5. sentinel value is a special value indicating the end of a list, such as a list of positive
integers ending with 0, as in 10 1 6 3 0.
6. while loop is a loop that repeatedly executes the loop body while the loop's
expression
evaluates to true
7. for loop is a loop consisting of a loop variable initialization, a loop expression,
and a loop variable update that typically describes iterating for a
specific number of times.
8. for Number of iterations is computable before the loop, like iterating N times.
9. while Number of iterations is not (easily) computable before the loop, like iterating
until the input is 'q'.
10. nested loop is a loop that appears in the body of another loop. The nested loops are
1/
5
, D278 section 4 Question and answers correctly solved
2025/2026
commonly referred to as the inner loop and outer loop.
11. while loop A while loop repeatedly executes the loop body while the loop's
expression evalu- ates to true.
2/
5