Repeat Until Loop Termination Analysis
A programmer is debugging code with an infinite loop. Which of the following best explains why the REPEAT UNTIL loop below never terminates?
sum ← 0
REPEAT UNTIL (sum > 100)
num ← INTEGER_INPUT
IF (num < 0) THEN
sum ← sum - num
ELSE
sum ← sum + num
END IF
A
The condition should be (sum ≥ 100)
B
User input makes the loop unpredictable
C
The loop lacks a counter variable
D
Subtracting a negative input increases sum, allowing it to exceed 100
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE