Totalling in a loop (8.1b)
Adds each new value to the running total inside a loop. Set Total <- 0 before the loop starts, then OUTPUT Total after the loop ends.
Understanding Totalling in a loop (8.1b) in IGCSE Computer Science Paper 2
What it does: The total is set to 0 before the loop. The FOR loop repeats 10 times and each time adds the new Number to Total. Total needs a known starting value of 0. Without it, the first Total + Number uses an unknown value. OUTPUT Total after the loop shows the final total once. Inside the loop it would print many partial totals, or an old one. 0 + 4 = 4, then 4 + 6 = 10, then 10 + 10 = 20. The total keeps building up. It does not just keep the last value. The rogue value only signals the end of input. If -1 is added, the total will be 1 too small.
Common mistakes: Total <- Number replaces the total with the latest value, so earlier values are lost. It should be Total <- Total + Number to add each value to the running total. A FOR loop uses the keyword TO for its end value, not UNTIL. It should be FOR Count <- 1 TO 3.
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 379–388) and word search (Modules 379–398).
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
Total <- Total + NumberFill in the Blanks
Spot the Error
Student with a class code? Join your class →