Practice question · Multiple choice
A while loop whose condition never becomes false runs forever. Why is proving termination genuinely harder than it sounds?
Hints
- What would you have to show about the loop variable to guarantee it stops?
- Ask whether a program could examine any other program and always answer 'does this halt?'
Show the answer
C. Because it needs a quantity that strictly decreases toward a bound
Why
Termination needs a decreasing measure bounded below, the same shape as an induction argument. And no general algorithm can settle it: Turing proved the halting problem undecidable, which is why compilers warn about suspicious loops rather than proving them safe.
Practise Loops and Iteration
The app has 6 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.