Index out of range
An error caused by using an index below the lower bound or above the upper bound, so the element does not exist. Example: Marks[31] in ARRAY[1:30] or Marks[0] when the lower bound is 1.
Understanding Index out of range in IGCSE Computer Science Paper 2
What it does: This condition is true only when the index lies within the bounds 1 to 30, so the element exists. The array has an upper bound of 30, so the final loop value of 31 is out of range. The loop should end at 30. The lower bound is 1, so index 0 is below the lower bound and does not exist. Marks[30] is the last valid element. The array starts at index 1, so Names[0] is out of range. This is a common off-by-one mistake from counting from zero.
Common mistakes: When i is 30, Marks[i + 1] is Marks[31]. The upper bound is 30, so this index is out of range. It should be Marks[i]. Count is 10, so n reaches 10. Scores only goes up to index 9, so Scores[10] is out of range. The loop must end at Count - 1.
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 449–458) and word search (Modules 439–458).
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
index out of rangeFill in the Blanks
Spot the Error
Student with a class code? Join your class →