← IGCSE Computer Science Paper 2

REPEAT ... UNTIL

A loop that runs its statements first, then tests the condition. It stops when the condition is TRUE, so the body always runs at least once. It has no ENDREPEAT keyword.

Understanding REPEAT ... UNTIL in IGCSE Computer Science Paper 2

What it does: Even though the condition is TRUE straight away, OUTPUT runs once before the test, showing the body always runs at least once. UNTIL with its condition closes the loop, so no ENDREPEAT is needed. The loop stops when Number > 0 is TRUE.

Common mistakes: A REPEAT loop must start with the keyword REPEAT. WHILE starts a different loop type that has no UNTIL at the end. Line 1 should be REPEAT. Pseudocode keywords must be written in upper case. Line 1 should be REPEAT, not 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 166–175) and word search (Modules 166–187).

Take this worksheet further — free with Cloodit

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

Learning
Duo
When does a REPEAT ... UNTIL loop test its condition?
After the body has runBefore the body runs
Matches
REPEAT INPUT Password ENDREPEAT
↓
There is no ENDREPEAT keyword. The loop must end with UNTIL and a condition such as UNTIL Password = "Secret".
Applying
Meanings
Term
REPEAT ... UNTIL
Meaning
A loop that runs its statements first, then tests the condition. It stops when the condition is TRUE, so the body always runs at least once. It has no ENDREPEAT keyword.
Practice
REPEAT
Testing
Gaps
Check Answer
Spots
1WHILE
2 OUTPUT "Enter password"

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

The 'Butterfly' badge — Branch Hopper, 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. When does a REPEAT ... UNTIL loop test its condition?
A. After the body has run ✓
B. Before the body runs
REPEAT is a post-condition loop. The statements run first, then the UNTIL condition is tested.
2. What is the minimum number of times the body of a REPEAT ... UNTIL loop runs?
A. Zero times if the condition is already TRUE
B. At least once ✓
The test comes at the end, so the body always runs once before the condition is checked. A WHILE loop is the one that can run zero times.
3. A REPEAT loop ends with UNTIL Password = "Secret". When does the loop stop?
A. When Password = "Secret" is FALSE
B. When Password = "Secret" is TRUE ✓
A REPEAT loop stops when the UNTIL condition becomes TRUE. While the condition is FALSE, the loop goes round again.
4. Which is the correct way to end a REPEAT loop?
A. UNTIL Password = "Secret" ✓
B. ENDREPEAT
There is no ENDREPEAT keyword. The UNTIL line closes the loop and holds the condition.
5. Which loop is more likely to run its body zero times?
A. WHILE ... DO ... ENDWHILE ✓
B. REPEAT ... UNTIL
WHILE tests first, so the body is skipped if the condition is FALSE at the start. REPEAT tests last, so it always runs once.

Match the Pairs

UNTIL Password = "Secret" → The loop stops as soon as Password equals "Secret", because UNTIL ends the loop when its condition is TRUE
REPEAT INPUT Password UNTIL Password = "Secret" → Asks for a password at least once, then keeps asking until the correct one is entered
A REPEAT loop tests its condition after the body, so the body always runs at least once → REPEAT OUTPUT "Hello" UNTIL TRUE
A REPEAT loop is closed by UNTIL and a condition. There is no ENDREPEAT keyword → REPEAT INPUT Number UNTIL Number > 0
REPEAT INPUT Password ENDREPEAT → There is no ENDREPEAT keyword. The loop must end with UNTIL and a condition such as UNTIL Password = "Secret".
REPEAT INPUT Password UNTIL Password <> "Secret" → The condition is the wrong way round. The loop stops when it is TRUE, so this stops on a wrong password. It should be UNTIL Password = "Secret".

Key Term

REPEAT ... UNTIL
A loop that runs its statements first, then tests the condition. It stops when the condition is TRUE, so the body always runs at least once. It has no ENDREPEAT keyword.

Fill in the Blanks

1. REPEAT INPUT Password UNTIL Password = "Secret"
Hint: Type the keyword that opens a loop whose condition is tested at the end, after the body has run once.
2. REPEAT INPUT Password UNTIL Password = "Secret"
Hint: Type the keyword that closes the loop and introduces the condition. There is no ENDREPEAT, so this one does the job.
3. REPEAT INPUT Password UNTIL Password = "Secret"
Hint: Type the relational operator that checks whether the variable is equal to the text. The loop stops when this is TRUE.
4. REPEAT INPUT Password UNTIL Password = "Secret"
Hint: Type the name of the variable that the loop condition tests. It holds what the user typed.
5. REPEAT INPUT Password UNTIL Password = "Secret"
Hint: Type the keyword that reads the user's entry into the variable. This is the statement in the loop body that runs at least once.

Spot the Error

Question 1
A WHILE
B OUTPUT "Enter password"
C INPUT Password
D UNTIL Password = "Secret"
Line A — A REPEAT loop must start with the keyword REPEAT. WHILE starts a different loop type that has no UNTIL at the end. Line 1 should be REPEAT.
Question 2
A repeat
B INPUT Guess
C Count ← Count + 1
D UNTIL Guess = 7
Line A — Pseudocode keywords must be written in upper case. Line 1 should be REPEAT, not repeat.
Question 3
A REPEAT
B INPUT Password
C ENDREPEAT
D OUTPUT "Welcome"
Line C — REPEAT has no ENDREPEAT keyword. The loop ends with UNTIL and a condition, so line 3 should be UNTIL Password = "Secret".
Question 4
A REPEAT
B INPUT Password
C UNTIL Password <> "Secret"
Line C — A REPEAT loop stops when the condition is TRUE. With <> it would stop on a wrong password and keep going on the right one. It should be UNTIL Password = "Secret".
Question 5
A REPEAT
B Count = Count + 1
C OUTPUT Count
D UNTIL Count = 5
Line B — Assignment uses the arrow ←, not =. The = sign is for comparing values. Line 2 should be Count ← Count + 1.

Student with a class code? Join your class →