← IGCSE Computer Science Paper 2

REPEAT…UNTIL post-condition loop

A post-condition loop: the body runs first, then UNTIL tests the condition. It always runs at least once and stops when the condition is TRUE. There is no ENDREPEAT.

Understanding REPEAT…UNTIL post-condition loop in IGCSE Computer Science Paper 2

What it does: Num is already above 5, but the body still runs once and outputs 10 before UNTIL tests the condition. UNTIL both ends the loop and holds the condition. Cambridge pseudocode has no ENDREPEAT. The fix is UNTIL Pin = 1234. The loop then stops when the correct PIN is entered.

Common mistakes: A REPEAT loop is closed by the UNTIL line, which holds the condition. There is no ENDREPEAT keyword. The line should be UNTIL Answer = "Y". REPEAT stands alone on its line. DO belongs to WHILE...DO, not to REPEAT...UNTIL. The line should be just REPEAT.

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 379–388) and word search (Modules 379–398).

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 tests its condition at which point?
After the body has runBefore the body runs
Matches
REPEAT INPUT Pin ENDREPEAT Pin = 1234
↓
ENDREPEAT does not exist. A REPEAT loop must finish with UNTIL followed by the condition.
Applying
Meanings
Term
REPEAT UNTIL
Meaning
A post-condition loop: the body runs first, then UNTIL tests the condition. It always runs at least once and stops when the condition is TRUE. There is no ENDREPEAT.
Practice
REPEAT
Testing
Gaps
Answer = "Y"
Check Answer
Spots
2 INPUT Answer
3ENDREPEAT

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

The 'Space Rabbit' badge — Launch Pad, 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 tests its condition at which point?
A. Before the body runs
B. After the body has run ✓
REPEAT...UNTIL is a post-condition loop. The body runs first, then UNTIL tests the condition.
2. The body of a REPEAT...UNTIL loop runs...
A. At least once, even if the condition is already TRUE ✓
B. Zero times if the condition is already TRUE
The test comes after the body, so the body always runs once before the condition is checked.
3. A REPEAT...UNTIL loop keeps looping while the condition is...
A. FALSE ✓
B. TRUE
UNTIL stops the loop when the condition becomes TRUE, so it keeps repeating while the condition is FALSE.
4. Which line correctly ends a REPEAT loop?
A. ENDREPEAT
B. UNTIL Answer = "Y" ✓
There is no ENDREPEAT in Cambridge pseudocode. The UNTIL line, with its condition, closes the loop.
5. Which statement about loop conditions is correct?
A. WHILE continues when TRUE, but REPEAT...UNTIL stops when TRUE ✓
B. WHILE and REPEAT...UNTIL both stop when the condition is TRUE
WHILE runs its body while the condition is TRUE. UNTIL ends the loop once its condition is TRUE.

Match the Pairs

REPEAT INPUT Answer UNTIL Answer = "Y" → Asks for Answer at least once, then keeps asking until the user types Y
UNTIL Count > 5 → The loop ends as soon as this condition becomes TRUE
A REPEAT loop always runs its body at least once, even if the condition is already TRUE at the start → Num <- 10 REPEAT OUTPUT Num UNTIL Num > 5
A REPEAT loop is closed by UNTIL and its condition, with no separate end keyword such as ENDREPEAT → REPEAT Total <- Total + 1 UNTIL Total = 10
REPEAT INPUT Pin ENDREPEAT Pin = 1234 → ENDREPEAT does not exist. A REPEAT loop must finish with UNTIL followed by the condition.
REPEAT INPUT Answer UNTIL Answer <> "Y" → The condition is the wrong way round. UNTIL stops when TRUE, so this stops on any answer except Y, instead of repeating until the user types Y.

Key Term

REPEAT UNTIL
A post-condition loop: the body runs first, then UNTIL tests the condition. It always runs at least once and stops when the condition is TRUE. There is no ENDREPEAT.

Fill in the Blanks

1. REPEAT INPUT Answer UNTIL Answer = "Y"
Hint: Type the keyword that closes the loop and holds the condition to test
2. REPEAT INPUT Answer UNTIL Answer = "Y"
Hint: Type the keyword that starts a post-condition loop
3. REPEAT INPUT Answer UNTIL Answer = "Y"
Hint: Type the relational operator that checks two values are equal
4. REPEAT INPUT Num UNTIL Num >= 1 AND Num <= 10
Hint: Type the logical operator that needs both tests to be TRUE before the loop stops
5. REPEAT Count <- Count + 1 UNTIL Count = 5
Hint: Type the variable that the loop changes and then tests

Spot the Error

Question 1
A REPEAT
B INPUT Answer
C ENDREPEAT
Line C — A REPEAT loop is closed by the UNTIL line, which holds the condition. There is no ENDREPEAT keyword. The line should be UNTIL Answer = "Y".
Question 2
A Count <- 0
B REPEAT DO
C Count <- Count + 1
D OUTPUT Count
E UNTIL Count = 5
Line B — REPEAT stands alone on its line. DO belongs to WHILE...DO, not to REPEAT...UNTIL. The line should be just REPEAT.
Question 3
A REPEAT
B OUTPUT "Enter a number"
C INPUT Num
D UNTIL Num < 1 OR Num > 10
Line D — REPEAT...UNTIL stops when the condition is TRUE. This condition is TRUE for invalid numbers, so the loop would stop on bad input. It should test for a valid number: UNTIL Num >= 1 AND Num <= 10.
Question 4
A REPEAT
B INPUT Password
C UNTIL Password == "cs2024"
Line C — Cambridge pseudocode uses a single = to compare values, not ==. The line should be UNTIL Password = "cs2024".
Question 5
A DO
B OUTPUT "Guess the number"
C INPUT Guess
D UNTIL Guess = Secret
Line A — A post-condition loop must start with the keyword REPEAT. DO is not used to begin a REPEAT...UNTIL loop. Line 1 should be REPEAT.

Student with a class code? Join your class →