Dry-running an algorithm and giving its output
Following an algorithm line by line with given data, recording each variable's value in a trace table, to find its output or purpose.
Understanding Dry-running an algorithm and giving its output in IGCSE Computer Science Paper 2
What it does: This line changes Total on every loop. You write the new value of Total in the trace table each time, using the given data. Assignment replaces the old value with the result of the right-hand side: 10 + 5 = 15. Nothing is output unless the line says OUTPUT. The loop runs for i = 1, 2, 3 and 4, which is 4 times. Count goes 0, 1, 2, 3, 4, so the final value is 4. A and B are numbers, so A + B adds them: 6 + 9 = 15. Joining digits as text (69) would not happen here.
Common mistakes: A FOR loop in Cambridge pseudocode is closed with NEXT i, not ENDFOR. Without NEXT i you cannot trace the loop, but with it the dry run gives Total = 1, 3, 6 and OUTPUT 6. N must go down so the condition N > 0 eventually becomes false. With N + 1 the trace table shows 3, 4, 5... forever. It should be N ← N - 1, giving OUTPUT 3, 2, 1.
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 307–316) 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
dry runFill in the Blanks
Spot the Error
Student with a class code? Join your class →