Spotting common mistakes in standard algorithms
A mistake in an algorithm's steps that lets it run but gives wrong results, e.g. a total not set to 0, a loop going past the array end, or using > instead of <.
Understanding Spotting common mistakes in standard algorithms in IGCSE Computer Science Paper 2
What it does: Starting with the first item means Max is always a real value from the data, avoiding the error of Max starting at 0. The division goes after NEXT, once Total and Count are complete. Dividing inside the loop gives a wrong result each time. TO 11 makes the loop run past the end of the array, so Marks[11] does not exist. The loop bound must be the last index, 10. Using > keeps the largest value, so it finds the maximum instead. To find the minimum, replace Min whenever you meet something smaller (<). Starting Max at 0 only works if values are never negative. A safer start is the first array element, Max ← Temp[1].
Common mistakes: Total must start at 0. Starting at 1 adds an extra 1 to the answer every time. It should be Total ← 0. Temp holds 7 values (one per day), so the loop must stop at 7. Going to 8 reads past the end of the array. It should be FOR i ← 1 TO 7.
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 296–306) and word search (Modules 296–316).
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
logic errorFill in the Blanks
Spot the Error
Student with a class code? Join your class →