Error: wrong loop bounds
A FOR loop with the wrong start or end value runs one time too many or too few, e.g. TO 9 instead of TO 10, or starting at 0 for a 1-based array. Check the bounds with a trace table.
Understanding Error: wrong loop bounds in IGCSE Computer Science Paper 2
What it does: The bounds 1 and 10 match the first and last indexes of the array, so the loop runs exactly 10 times. Count the start value too: 0, 1, 2, 3, 4 is 5 values. Number of runs = end - start + 1. 1 TO 8 gives 8 passes. 1 TO 7 gives only 7, which is an off-by-one error. An off-by-one error is a wrong bound that changes the number of repeats by exactly one. A loop that never stops is a different error. IGCSE arrays usually start at index 1, so starting the loop at 0 is an off-by-one error with the start value.
Common mistakes: This is an off-by-one error. The comment says to add 1 to 10, but TO 9 stops one time too soon, so 10 is never added. It should be FOR Count ← 1 TO 10. The array is 1-based, so index 0 does not exist. Starting at 0 also makes the loop run 6 times instead of 5. It should be FOR Index ← 1 TO 5.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 232–241) and word search (Modules 232–253).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
off-by-one errorFill in the Blanks
Spot the Error
Student with a class code? Join your class →