← IGCSE Computer Science Paper 2

REPEAT…UNTIL loop (7d)

A loop that runs its lines first, then checks the UNTIL condition. It stops when the condition is TRUE, so the body always runs at least once.

Understanding REPEAT…UNTIL loop (7d) in IGCSE Computer Science Paper 2

What it does: Num > 10 is already TRUE at the start, but OUTPUT still runs once before the condition is checked. WHILE tests the condition at the top, so the body is skipped if it is FALSE straight away. REPEAT would always run once. REPEAT runs the lines first and only then checks the UNTIL condition, so the check comes at the end of each pass. UNTIL states when to STOP. You stop when the number is valid, so the condition describes a valid number. The other option describes an invalid number and would keep the loop going on valid input. Cambridge pseudocode has no ENDREPEAT. The closing line is UNTIL followed by the stopping condition.

Common mistakes: In Cambridge pseudocode, values are assigned with ←, not =. The line should be Num ← Num * 2. The = sign is used to compare values. Count is reset to 1 on every pass, so it can never count more than one. The line should be Count ← Count + 1 to add one each time the loop runs.

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 265–274) and word search (Modules 254–274).

Take this worksheet further — free with Cloodit

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

Learning
Duo
A REPEAT…UNTIL loop checks its condition at the END of each pass. True or false?
TrueFalse
Matches
REPEAT Count ← Count + 1 ENDREPEAT
↓
REPEAT loops end with UNTIL and a condition, not ENDREPEAT. The loop needs UNTIL Count = 5 or similar.
Applying
Meanings
Term
REPEAT ... UNTIL condition
Meaning
A loop that runs its lines first, then checks the UNTIL condition. It stops when the condition is TRUE, so the body always runs at least once.
Practice
REPEAT
Testing
Gaps
Guess = 7
Check Answer
Spots
2REPEAT
3 Num = Num * 2

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

The 'Cosmic Owl' badge — Comprehension Guru, 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 REPEAT…UNTIL loop checks its condition at the END of each pass. True or false?
A. True ✓
B. False
REPEAT runs the lines first and only then checks the UNTIL condition, so the check comes at the end of each pass.
2. Which loop always runs its body at least once?
A. WHILE … DO … ENDWHILE
B. REPEAT … UNTIL ✓
REPEAT runs the body before it checks the condition. A WHILE loop checks first, so its body may never run.
3. A REPEAT loop stops when the UNTIL condition is…
A. FALSE
B. TRUE ✓
UNTIL is the stopping condition. The loop keeps repeating while it is FALSE and stops as soon as it becomes TRUE.
4. Count ← 10 REPEAT Count ← Count + 1 UNTIL Count > 5 How many times does the loop body run?
A. 1 time ✓
B. 0 times
The body runs once, making Count 11. Then Count > 5 is TRUE, so the loop stops. REPEAT never skips its first pass.
5. Which is the correct way to write a loop that asks for a number until the user enters 1 to 10?
A. UNTIL Num >= 1 AND Num <= 10 ✓
B. UNTIL Num < 1 OR Num > 10
UNTIL states when to STOP. You stop when the number is valid, so the condition describes a valid number. The other option describes an invalid number and would keep the loop going on valid input.

Match the Pairs

REPEAT INPUT Guess UNTIL Guess = 7 → Asks for a guess at least once and keeps asking until the guess equals 7
UNTIL Count = 10 → The stopping condition: the loop ends when Count equals 10 and repeats while it is FALSE
A REPEAT loop always runs its body at least once, because the condition is checked after the body → Num ← 50 REPEAT OUTPUT Num UNTIL Num > 10
A WHILE loop checks first and may never run, but a REPEAT loop runs once before it checks → WHILE Num < 5 DO Num ← Num + 1 ENDWHILE
REPEAT Count ← Count + 1 ENDREPEAT → REPEAT loops end with UNTIL and a condition, not ENDREPEAT. The loop needs UNTIL Count = 5 or similar.
REPEAT Count ← Count + 1 UNTIL Count < 0 → The UNTIL condition can never become TRUE because Count only goes up, so the loop never stops. It needs a condition such as Count = 10.

Key Term

REPEAT ... UNTIL condition
A loop that runs its lines first, then checks the UNTIL condition. It stops when the condition is TRUE, so the body always runs at least once.

Fill in the Blanks

1. REPEAT INPUT Guess UNTIL Guess = 7
Hint: Type the keyword that ends the loop and introduces its stopping condition.
2. REPEAT Count ← Count + 1 UNTIL Count = 5
Hint: Type the keyword that starts a loop which always runs its body once before checking the condition.
3. REPEAT INPUT Password UNTIL Password = "open"
Hint: Type the comparison operator that checks whether two values are equal.
4. REPEAT INPUT Number UNTIL Number >= 1 AND Number <= 10
Hint: Type the logical operator that makes both parts of the stopping condition true together.
5. REPEAT Lives ← Lives - 1 UNTIL Lives <= 0
Hint: Type the comparison operator meaning less than or equal to, so the loop stops when lives run out.

Spot the Error

Question 1
A Num ← 1
B REPEAT
C Num = Num * 2
D UNTIL Num > 100
E OUTPUT Num
Line C — In Cambridge pseudocode, values are assigned with ←, not =. The line should be Num ← Num * 2. The = sign is used to compare values.
Question 2
A Count ← 0
B REPEAT
C INPUT Mark
D Count ← 1
E UNTIL Mark = -1
F OUTPUT Count
Line D — Count is reset to 1 on every pass, so it can never count more than one. The line should be Count ← Count + 1 to add one each time the loop runs.
Question 3
A Attempts ← 0
B WHILE Code ≠ 1234 DO
C INPUT Code
D Attempts ← Attempts + 1
E UNTIL Code = 1234
Line B — A loop that ends with UNTIL must start with REPEAT. WHILE...DO belongs with ENDWHILE. The line should be just REPEAT.
Question 4
A Num ← 10
B REPEAT
C Num ← Num + 2
D UNTIL Num <= 0
E OUTPUT Num
Line C — Num goes up, so Num <= 0 never becomes TRUE and the loop never stops. The line should be Num ← Num - 2 so that Num counts down to the stopping condition.
Question 5
A DECLARE Age : INTEGER
B DO
C INPUT Age
D UNTIL Age >= 1 AND Age <= 120
Line B — DO is not the keyword that starts a post-condition loop. The loop must open with REPEAT to match the UNTIL line that closes it.

Student with a class code? Join your class →