Counters and accumulators in pseudocode
A counter. It adds 1 to a variable each time a loop repeats. Set it to 0 before the loop. An accumulator works the same way: total <- total + x adds a value each time.
Understanding Counters and accumulators in pseudocode in VCE Software Development U3O1
What it does: The starting value count <- 0 comes before the loop, so the counter begins at zero and is not reset on each repeat. Putting the counter update inside an if block means it only increases when the item matches the condition. count <- count + 1 takes the old value and adds 1. count <- 1 just resets it to 1 every time. total <- total + mark adds each mark to the running total. total <- mark throws away the old total each time. The counter goes up by 1 on each of the 5 repeats: 1, 2, 3, 4, 5. It ends at 5.
Common mistakes: The running total must be set to 0 before the loop. Starting it at n adds an extra n to the answer. It should be total <- 0. This line replaces count with 1 each time instead of adding 1, so count never gets above 1. It should be count <- count + 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 48–71) and word search (Modules 10–71).
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 →