Learn in your language
Skip to content
IGCSE · Cambridge (CIE) · 0984

Run a loop at least once

Use REPEAT…UNTIL when the body must run before the stop condition is tested.

Section 8 · Programming

Cambridge IGCSE Computer Science 0984 · Programming · 2026–2028 Version 4 · 0984 (9–1) · 8.1
Exam scope and assessment notes

This sequence follows Cambridge IGCSE Computer Science 0984, 2026–2028 syllabus Version 4. It covers section 8.1 (Programming concepts) only. Pseudocode examples use the published Cambridge format; the separate 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers, a browser-based programming workspace and human subject-teacher review remain outstanding. Cambridge states that 0984 has the same 2026–2028 subject content as 0478, with 9–1 grading. In June and November, Cambridge lists 0984 in Administrative zone 3 and for centres in Oman and the UAE. Confirm availability for your centre and exam series with Cambridge International. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes.

Before you begin

  • Be comfortable following an ordered algorithm and tracing variable values. Each lesson introduces the Cambridge pseudocode form it uses.

Work on paper. Try each question before revealing help, and explain why your method works.

Quick readiness check

Does a REPEAT body run when the stop condition would already be true?

What you will learn

  • Recognise post-condition iteration
  • Write the stop condition correctly
  • Explain why the body always runs at least once

REPEAT checks after the body

A post-condition loop executes its statements first, then tests the UNTIL condition. Therefore its body runs at least once.

UNTIL stops when the condition becomes TRUE. This is the opposite wording from WHILE, which continues while its condition remains TRUE.

Read the condition as a stop rule

For input validation, repeat asking while the value is unsuitable, then stop UNTIL it is in range. Use parentheses and a clear Boolean expression for two-sided boundaries.

Update the condition's variables during the body. If the stop condition never becomes true, the loop will continue indefinitely.

Pause and explain

A loop should stop after a valid age from 0 to 120 is entered. Which stop condition is correct?

Put the idea to work

Worked example

Keep asking for a rating until the user enters a value from 1 to 5 inclusive.

Show the worked solution
  1. Read Rating once in the loop body.
  2. The loop should stop when Rating >= 1 AND Rating <= 5.
  3. Invalid values cause another pass; a valid value ends the loop.

Answer REPEAT OUTPUT "Enter a rating from 1 to 5" INPUT Rating UNTIL (Rating >= 1) AND (Rating <= 5)

Try a topic test

Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.

Test this topic →

From guided practice to a new situation

Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.

1 · Guided

A REPEAT loop reads Number and stops UNTIL Number = 0. What happens if the first value is 0?

Give me a hint

The input has already been read once before testing.

Compare my reasoning
  1. The body prompts and reads 0.
  2. The condition is checked after the read.
  3. The loop stops after one pass.

The body runs once, reads 0, then the loop stops.

Look for these in your work

  • Order identified
  • At-least-once result
2 · Independent

Write a REPEAT loop that asks again until PIN is exactly four characters long.

Give me a hint

The stop condition is the valid case.

Compare my reasoning
  1. Read PIN inside the loop.
  2. Check LENGTH(PIN) = 4.
  3. The loop stops when that equality is true.

REPEAT INPUT PIN UNTIL LENGTH(PIN) = 4

Look for these in your work

  • Read inside body
  • Correct stop condition
3 · Transfer

An author writes REPEAT INPUT Mark UNTIL Mark < 0 to ask for a non-negative mark. Explain the defect and correct it.

Give me a hint

UNTIL should describe a valid stopping condition.

Compare my reasoning
  1. Mark < 0 is invalid input.
  2. The current loop stops on a negative mark.
  3. Use Mark >= 0 as the stop condition.

Change the condition to UNTIL Mark >= 0 so the loop ends for an accepted mark.

Look for these in your work

  • Defect identified
  • Condition corrected

Common mistakes

  • Using the condition for continuing instead of stopping
  • Forgetting that REPEAT executes before checking
  • Writing an invalid condition that accepts values outside the range
Recall without your notes

What can you explain now?

When is the UNTIL condition checked?

Compare with the explanation

After the loop body

A REPEAT loop is post-condition iteration.

After trying it yourself, choose your next review. This is your self-assessment.

Your review choice appears on Today. Sign in to sync it across devices.

Make it stick

How does the meaning of UNTIL differ from the condition in WHILE?

If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.

Keep learning Computer Science (9-1)

Course scope and assessment

165 original lessons map the listed objectives across all 10 main topics in the 2026–2028 Version 4 syllabus. Cambridge states that 0984 has the same subject content as 0478, with 9–1 grading. Three retained introductory lessons remain available but are not counted as syllabus-mapped teaching. The 2023–2025 syllabus remains unmapped. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes. In June and November, Cambridge lists 0984 in Administrative zone 3 and for centres in Oman and the UAE. Confirm availability for your centre and exam series with Cambridge International. Practical programming in an executable browser workspace, full timed-paper practice and human subject-teacher review remain outstanding. Practice is self-checked and does not award an official Cambridge grade.

StudyForA · Learn with understanding

Original teaching content and links to official sources. Check your exam year and qualification before using a resource.