| preferred AP College board partner for AP classes
hard Solved by 3 students
Repeat Until Loop Termination Analysis
< Prev
Next >

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

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.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy