Tracing assignments to find a variable's value
A table with one column per variable. Follow the program line by line and write each variable's new value after every assignment, so you can predict the final OUTPUT.
Understanding Tracing assignments to find a variable's value in IGCSE Computer Science Paper 2
What it does: Following the assignments in order, Total changes from 4 to 12, so the final OUTPUT is 12. 47 DIV 10 is 4 and 47 MOD 10 is 7, so the trace table records Tens as 4 and Units as 7. The second line uses the old value of X (5), adds 2, and stores 7 back in X. Write 7 as the new value in the trace table. Each repeat adds 1 to the current value, so Counter goes 0, 1, 2, 3. It does not reset to 1 each time. 17 DIV 5 gives the whole number of times 5 fits, which is 3. 17 MOD 5 gives the remainder, which is 2.
Common mistakes: An assignment puts the variable on the left of the arrow and the expression on the right. When tracing, Count becomes 0 and then 1. The line should be Count ← Count + 1. DECLARE needs a colon between the identifier and its data type. It should be DECLARE Total : INTEGER. After the later lines, the trace table shows Total as 5, then 10.
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 337–346) and word search (Modules 337–357).
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 →