Tracing counting and totalling
Trace table for counting and totalling: Count and Total start at 0 in the first row, change each pass (Count only if the IF is true), and the final values are output after the loop.
Understanding Tracing counting and totalling in IGCSE Computer Science Paper 2
What it does: The count line sits inside the IF, so Count goes up only when Number is greater than 50. OUTPUT comes after NEXT, so the values appear once, in the last row of the trace table. The first row records the starting values set by the initialisation lines, so both show 0 before the loop runs. Total ← Total + Number adds the new value to the old total: 10 + 5 = 15. It does not replace the total with Number. Only 60 and 72 are >= 50, so the IF is true twice. 45 does not add to Count, so the final Count is 2.
Common mistakes: Counting goes up by 1 on each pass, so the line must be Count ← Count + 1. Subtracting would make the Count column in the trace table go 0, -1, -2 and so on. A running total must add each new value to the old total: Total ← Total + Num. Writing Total ← Num overwrites the total every pass, so the trace table would only show the last input.
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 83–92) and word search (Modules 71–92).
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
Count ← Count + 1Fill in the Blanks
Spot the Error
Student with a class code? Join your class →