Tracing a decision inside a loop with a trace table
A table with one row per loop repeat. Record the IF condition result, change only the variables the branch updates, copy the rest down, and note any output.
Understanding Tracing a decision inside a loop with a trace table in ACARA Digital Technologies Years 7–8
What it does: The count stays the same on rows where the IF is false and only goes up on rows where it is true, so the repeated numbers show the copy-down rule. The row shows the value of i, the condition being tested and its result. This tells you which branch to follow for that repeat. A trace table has one row per repeat of the loop. Each pass through the loop gets its own row, even if the IF does nothing. Only the variables changed by the branch taken get new values. Everything else is copied down from the row above.
Common mistakes: This trace is for total starting at 0, adding n only when n is even. At n = 2 the condition is Yes, so total = 0 + 2 = 2, not 3. When n is 2, the condition n > 3 is false, so the result column must say No. The row wrongly says Yes, but the score did not change.
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 420–481) and word search (Modules 420–519).
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 →