← ACARA Digital Technologies Years 5–6

A variable that counts in a loop

Makes a counter. Set count to 0 before the loop, ADD 1 TO count inside the loop each time it repeats, then SHOW count after the loop.

Understanding A variable that counts in a loop in ACARA Digital Technologies Years 5–6

What it does: SHOW count goes after the loop, so it displays the final total once the repeating is done. ADD 1 TO count makes the number bigger each time. SET count TO 1 would just put the counter back to 1 again. The counter goes 1, 2, 3, 4, 5. After 5 repeats it holds 5. Set the counter to 0 first, add 1 inside the loop, then show it. Putting SET inside the loop resets the counter every time. SET count TO 0 is the starting step of a counter, placed before the loop begins.

Common mistakes: A counter must start at 0 before the loop. Starting at 1 makes the final count one too big. It should be SET count TO 0. The counter is called count, but this line shows a variable called total that was never made. It should be SHOW count.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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 106–119) and word search (Modules 106–132).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Where should SET count TO 0 go when you use a counter with a loop?
Inside the loopBefore the loop starts
Matches
REPEAT 5 TIMES SET count TO 0 ADD 1 TO count SHOW count
↓
SET count TO 0 is inside the loop, so the counter resets to 0 on every repeat. It must go before the loop so the count can build up.
Applying
Meanings
Term
SET count TO 0
Meaning
Makes a counter. Set count to 0 before the loop, ADD 1 TO count inside the loop each time it repeats, then SHOW count after the loop.
Practice
SET count TO 0
Testing
Gaps
SET count TO
Check Answer
Spots
1SET count TO 1
2REPEAT 5 TIMES

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Hippopotamus' badge — Savannah Titan, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Where should SET count TO 0 go when you use a counter with a loop?
A. Before the loop starts ✓
B. Inside the loop
The counter must start at 0 once, before the loop. If it is set inside the loop, it goes back to 0 every time and never counts up.
2. Which line makes the counter go up by 1 each time the loop repeats?
A. SET count TO 1
B. ADD 1 TO count ✓
ADD 1 TO count makes the number bigger each time. SET count TO 1 would just put the counter back to 1 again.
3. Where should ADD 1 TO count go?
A. After the loop
B. Inside the loop ✓
The ADD line must be inside the loop so it runs once for every repeat. After the loop it would only run one time.
4. A loop runs 5 times. Each time it runs ADD 1 TO count. The counter started at 0. What does SHOW count display after the loop?
A. 5 ✓
B. 1
The counter goes 1, 2, 3, 4, 5. After 5 repeats it holds 5.
5. When is the best time to SHOW count if you want the total number of repeats?
A. After the loop has finished ✓
B. Before the loop starts
Before the loop the counter is still 0. Show it after the loop to see the final count.

Match the Pairs

SET count TO 0 → Makes a counter that starts at zero. It goes before the loop so the count begins fresh.
ADD 1 TO count → Makes the counter go up by one. It goes inside the loop so it grows each time the loop repeats.
Show how many times the loop ran by displaying the counter after the loop has finished → SHOW count
A counter starts at 0, then goes up by 1 each time the loop repeats, then the total is shown at the end → SET count TO 0 REPEAT 5 TIMES ADD 1 TO count SHOW count
REPEAT 5 TIMES SET count TO 0 ADD 1 TO count SHOW count → SET count TO 0 is inside the loop, so the counter resets to 0 on every repeat. It must go before the loop so the count can build up.
SET count TO 0 REPEAT 5 TIMES SHOW count ADD 1 TO count → ADD 1 TO count is after the loop and SHOW count is inside it. The counter should go up inside the loop and be shown after the loop.

Key Term

SET count TO 0
Makes a counter. Set count to 0 before the loop, ADD 1 TO count inside the loop each time it repeats, then SHOW count after the loop.

Fill in the Blanks

1. SET count TO 0 REPEAT 5 TIMES ADD 1 TO count
Hint: Type the starting number a counter gets before the loop begins.
2. SET count TO 0 REPEAT 5 TIMES ADD 1 TO count
Hint: Type the keyword that makes the counter go up inside the loop.
3. SET count TO 0 REPEAT 4 TIMES ADD 1 TO count
Hint: Type the amount added to the counter each time the loop repeats.
4. SET count TO 0 REPEAT 6 TIMES: ADD 1 TO count SHOW count
Hint: Type the keyword that displays the counter after the loop has finished.
5. SET count TO 0 REPEAT 3 TIMES ADD 1 TO count
Hint: Type the name of the variable that was set to 0 before the loop.

Spot the Error

Question 1
A SET count TO 1
B REPEAT 5 TIMES
C ADD 1 TO count
D SHOW count
Line A — A counter must start at 0 before the loop. Starting at 1 makes the final count one too big. It should be SET count TO 0.
Question 2
A SET count TO 0
B REPEAT 4 TIMES
C ADD 1 TO count
D SHOW total
Line D — The counter is called count, but this line shows a variable called total that was never made. It should be SHOW count.
Question 3
A SET claps TO 0
B REPEAT 8
C ADD 1 TO claps
D SHOW claps
Line B — The loop line must say how many times to repeat. The word TIMES is missing. It should be REPEAT 8 TIMES.
Question 4
A SET laps TO 0
B REPEAT 5 TIMES
C ADD 0 TO laps
D SHOW laps
Line C — Adding 0 never changes the counter, so it stays at 0. A counter goes up by 1 each time the loop repeats. It should be ADD 1 TO laps.
Question 5
A SET stars TO 0
B REPEAT UNTIL stars = 0
C ADD 1 TO stars
D SHOW stars
Line B — stars starts at 0, so the loop would stop straight away and never repeat. The loop should run until stars = 7.

Student with a class code? Join your class →