Tracing a loop in a trace table
Work through the loop body once per pass, recording changed values in a new row each time. Test the condition before the body for WHILE and after it for REPEAT. Check the final row.
Understanding Tracing a loop in a trace table in IGCSE Computer Science Paper 2
What it does: This FOR loop gives the counter values 1, 2, 3 and 4, so the trace table has four rows for the counter. A WHILE loop tests first. If the condition is false at the start, the body never runs. A FOR loop includes both the start and the end value. Counter takes 2, 3, 4 and 5, so there are 4 passes. Record the changed values in a new row each time through the loop body. Skipping passes loses the steps and the marks. Total goes 1, 3, 6 on the three passes. The final row shows N = 3 and Total = 6, so always check the final row.
Common mistakes: Count starts at 4 and the end value is 1, so with the default step of +1 the body never runs and the trace table has no loop rows. It should be FOR Count ← 1 TO 4, which gives Count values 1, 2, 3, 4. A WHILE loop header ends with DO, not THEN (THEN belongs to IF). The condition is tested before each pass of the body, so the line should be WHILE Num < 3 DO.
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 216–231) and word search (Modules 188–231).
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
Tracing a loopFill in the Blanks
Spot the Error
Student with a class code? Join your class →