Counting in a loop (8.1b)
Adds 1 to the counter each time the thing being counted happens. Set Count <- 0 before the loop, and put this inside the loop (inside an IF to count only some values).
Understanding Counting in a loop (8.1b) in IGCSE Computer Science Paper 2
What it does: The IF means Count only goes up when the condition is true, so only values that meet the condition are counted. The counter must be set to 0 once, before the loop. If it were inside the loop, it would reset to 0 on every repeat and you would lose the count. The variable being changed goes on the left of the arrow. Count <- Count + 1 takes the old value, adds 1 and stores it back in Count. The counting line must be between THEN and ENDIF so the condition controls it. In the wrong answer the IF is empty, so every value is counted.
Common mistakes: The counter must start at 0 before the loop. Starting at 1 makes the final count one too high. It should be Count <- 0. Count = 0 is a comparison, not an assignment. To set the counter to 0 you must write Count <- 0.
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
Count <- Count + 1Fill in the Blanks
Spot the Error
Student with a class code? Join your class →