← ACARA Digital Technologies Years 5–6

A loop that never stops

A loop that never stops because its stopping condition can never become true. Something inside the loop, like a counter, must change to work towards the condition.

Understanding A loop that never stops in ACARA Digital Technologies Years 5–6

What it does: This step changes count each time round, so it gets closer to the number that stops the loop. An infinite loop keeps going because nothing makes the stopping condition true. The number of steps does not matter. Changing the variable is not enough. It must change in a way that works towards the stopping condition. Taking 1 away from n each time counts down to 0. Adding 1 makes n bigger and bigger, so it never reaches 0. A step after the loop only runs when the loop ends. It cannot help the loop stop. It must be inside the loop.

Common mistakes: The count starts at 1 and goes up, so it can never equal 0. The loop never stops. It should say REPEAT UNTIL count = 5. Lives start at 3 and go down, so they will never reach 5. The stopping condition must be something the loop works towards: REPEAT UNTIL lives = 0.

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
A loop that never stops is called an infinite loop. What makes a loop never stop?
Its stopping condition can never become trueIt has too many steps inside it
Matches
SET count TO 0 REPEAT UNTIL count = 3 SAY "Hi"
↓
The counter is never changed inside the loop, so count stays 0 and the loop never stops. Add SET count TO count + 1 inside the loop.
Applying
Meanings
Term
infinite loop
Meaning
A loop that never stops because its stopping condition can never become true. Something inside the loop, like a counter, must change to work towards the condition.
Practice
count ← 1
Testing
Gaps
SET TO count + 1
Check Answer
Spots
1SET count TO 1
2REPEAT UNTIL count = 0

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

The 'Armadillo' badge — Shield Bearer, 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. A loop that never stops is called an infinite loop. What makes a loop never stop?
A. It has too many steps inside it
B. Its stopping condition can never become true ✓
An infinite loop keeps going because nothing makes the stopping condition true. The number of steps does not matter.
2. Which algorithm has a loop that never stops? SET count TO 1 REPEAT UNTIL count = 5 SAY "Hi"
A. It never changes count, so count stays at 1 forever ✓
B. It stops after it says Hi five times
count starts at 1 and nothing adds to it. count = 5 never becomes true, so the loop never stops.
3. Which line, placed inside the loop, fixes the loop that never stops? SET count TO 1 REPEAT UNTIL count = 5 SAY "Hi"
A. SAY "Stop"
B. ADD 1 TO count ✓
Adding 1 to count each time moves it towards 5. Then the stopping condition finally becomes true.
4. A loop says REPEAT UNTIL lives = 0. Inside the loop, lives goes UP by 1 each time. What happens?
A. The loop never stops, because lives moves away from 0 ✓
B. The loop stops quickly, because lives is changing
Changing the variable is not enough. It must change in a way that works towards the stopping condition.
5. Which loop will stop?
A. SET n TO 10, then REPEAT UNTIL n = 0: SUBTRACT 1 FROM n ✓
B. SET n TO 10, then REPEAT UNTIL n = 0: ADD 1 TO n
Taking 1 away from n each time counts down to 0. Adding 1 makes n bigger and bigger, so it never reaches 0.

Match the Pairs

REPEAT UNTIL count = 5 → The loop stops only when count becomes 5, so count must change inside the loop
REPEAT UNTIL count = 5 (no change to count) → An infinite loop, because count never changes and so never reaches 5
Adding 1 to the counter inside the loop works towards the stopping condition → SET count TO count + 1
A loop that fixes the problem has a step that moves the variable towards the stop value → REPEAT UNTIL lives = 0: SET lives TO lives - 1
SET count TO 0 REPEAT UNTIL count = 3 SAY "Hi" → The counter is never changed inside the loop, so count stays 0 and the loop never stops. Add SET count TO count + 1 inside the loop.
SET steps TO 10 REPEAT UNTIL steps = 0 SET steps TO steps + 1 → The variable changes in the wrong direction. Steps goes up away from 0, so the loop never stops. It should be steps - 1.

Key Term

infinite loop
A loop that never stops because its stopping condition can never become true. Something inside the loop, like a counter, must change to work towards the condition.

Fill in the Blanks

1. SET count TO 0 REPEAT UNTIL count = 5 SET count TO count + 1
Hint: Type the variable that must change inside the loop so it can reach the stopping value.
2. SET lives TO 3 REPEAT UNTIL lives = 0 SET lives TO lives - 1
Hint: Type the keyword that comes before the stopping condition of the loop.
3. SET count TO 1 REPEAT UNTIL count = 10 SET count TO count + 1
Hint: Type the operator that moves count upwards towards the stopping number.
4. SET steps TO 0 REPEAT UNTIL steps = 4 SET steps TO steps + 1
Hint: Type the variable name that the loop checks to decide when to stop.
5. SET water TO 5 REPEAT UNTIL water = 0 SET water TO water - 1
Hint: Type the operator that makes the number go down so the loop can finish at zero.

Spot the Error

Question 1
A SET count TO 1
B REPEAT UNTIL count = 0
C SAY count
D SET count TO count + 1
Line B — The count starts at 1 and goes up, so it can never equal 0. The loop never stops. It should say REPEAT UNTIL count = 5.
Question 2
A SET lives TO 3
B REPEAT UNTIL lives = 5
C SET lives TO lives - 1
D SAY "Ouch!"
Line B — Lives start at 3 and go down, so they will never reach 5. The stopping condition must be something the loop works towards: REPEAT UNTIL lives = 0.
Question 3
A SET steps TO 1
B REPEAT UNTIL steps = 10
C SET steps TO steps + 2
D SAY steps
Line A — Starting at 1 and adding 2 gives 1, 3, 5, 7, 9, 11. It skips 10 and never stops. The start should be SET steps TO 0 so the counting lands on 10.
Question 4
A SET score TO 0
B REPEAT UNTIL score >= 20
C SET score TO score - 5
D SAY score
Line C — The score goes down (0, -5, -10...), so it can never reach 20. The loop must add to move towards the condition: SET score TO score + 5.
Question 5
A SET water TO 5
B SAY "Emptying bucket"
C REPEAT UNTIL water = 0
D SET water TO water
E SAY water
Line D — The variable water never changes, so it never reaches 0 and the loop runs forever. The loop needs SET water TO water - 1.

Student with a class code? Join your class →