Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
hard Solved by 1 students

Repeat Until Loop Termination Analysis

Mark
< Prev
Next >

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

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|