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