Tracing a 1D array program with a trace table
A table that records the loop variable, index and array contents after each pass of a loop, so you can predict the final OUTPUT and spot errors such as off-by-one.
Understanding Tracing a 1D array program with a trace table in IGCSE Computer Science Paper 2
What it does: Each pass adds one element to Total. The last row of the trace table shows the value that OUTPUT displays. Each pass of the loop gets its own row. This lets you see exactly how the values change. The upper bound is 5. The loop must stop at 5, so a row with Index = 6 reveals the off-by-one error. Trace it: i = 2 changes Max to 8; i = 3 compares 2 > 8, which is false, so Max stays 8.
Common mistakes: The index must be the loop variable Index. Using Total as the index means the trace table shows the wrong elements being read. It should be Score[Index]. The trace table only fills Num[1] to Num[4]. Num[5] is outside the array (or never set). It should be OUTPUT Num[4], which gives 8.
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 459–468) and word search (Modules 459–478).
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
trace tableFill in the Blanks
Spot the Error
Student with a class code? Join your class →