Using a trace table to find an error
In a trace table, the first row where a value differs from what you expected points to the faulty line of the algorithm. Look at that line, then suggest a correction.
Understanding Using a trace table to find an error in IGCSE Computer Science Paper 2
What it does: The loop ended one pass too soon because the end value was 4. The corrected header FOR Count ← 1 TO 5 gives the five passes expected. If Count started at 1 or was never set, every row is wrong from the first one. The fix is the initialising line Count ← 0 before the loop. Using > instead of >= leaves out the boundary value. The trace table shows the error at Mark = 50, so the operator is the fault. Errors carry forward, so the later wrong values are usually caused by the first one. Always start at the first wrong row.
Common mistakes: The loop ends one pass too soon. The trace table stops with Count = 4 when 5 was expected, and the last row points back to the FOR line. It should be FOR Index ← 1 TO 5. Using > instead of >= gives the wrong result for 50. When the trace table is filled in with a Mark of 50, Pass stays FALSE instead of becoming TRUE. The condition should be IF Mark >= 50 THEN.
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 83–92) and word search (Modules 71–92).
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
first wrong valueFill in the Blanks
Spot the Error
Student with a class code? Join your class →