What does infinite loop mean?
A loop whose condition never becomes false, so it never ends. Sometimes wanted (a robot's main loop), often a bug (a loop that forgets to change what it tests).
In a lesson
A
whilewhose condition never becomesFalseruns forever: an infinite loop. Run this one; the simulator stops it once it has printed far too much, but a real robot would carry on until its battery died:
Learn it
- Taught in F2.6 Condition-controlled loops: while Decisions and loops, GCSE
Used in
- A2.3 Recursion versus iteration
- A6.8 Computable problems and the Halting problem
- A6.10 Project: the mission robot