Module 6 · Loops and Jump Statements
Bug Gallery: Off by One, Infinite, and the Missing Brace
ProReading
Bob wrote five loops after lunch. One printed a seat list one short, and one never stopped. One ran its body once, one forgot two marks, and one would not let the till close. Bob calls it a productive afternoon.
Pro lesson
This one goes deeper
It is included with this track and with Learn Pro. Every question on the Skill Test can be answered from the free lessons, so this is depth and never a gate on the certificate.
What is inside Bug Gallery: Off by One, Infinite, and the Missing Brace
- Off by one: a loop that runs once too many or once too few
- The infinite loop: nothing moves the condition
- Reading Time limit exceeded: never ends, or ends too late
- The Zune freeze: a path through the body that takes no step
- The unsigned countdown that never ends
- The stray semicolon after the header
- The missing brace
- The loop variable changed in the body
- One equals sign in the condition
- What GCC 12 says about each bug
- The five-question loop checklist