Using a variable as a counter in a loop
A counter is a variable that goes up by 1 each time a loop repeats, so it counts how many times something happened. Set it to 0 before the loop starts.
Understanding Using a variable as a counter in a loop in Years 5–6 Creating Digital Solutions
What it does: The loop keeps going until the counter equals 5, so the counter decides when the loop stops. Adding 1 each time the loop repeats makes the counter go up. Setting it to 0 inside the loop would wipe out the count every time. A counter does not change the speed of the loop. It just remembers how many times something has happened.
Common mistakes: The counter starts at 0, so 'counter = 0' is already true and the loop never runs. The loop should stop when the counter reaches the target number, so it should be REPEAT UNTIL counter = 5. Subtracting 1 makes the counter go down (-1, -2, ...), so it never reaches 3 and the loop never stops. A counter goes up by 1 each time, so it should be counter ← counter + 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 61–74) and word search (Modules 41–74).
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
counter ← counter + 1Fill in the Blanks
Spot the Error
Student with a class code? Join your class →