REPEAT num ← INT(USERINPUT) UNTIL num > 0 OUTPUT num
Always runs at least once — good for input validation
Choosing a Loop
Which Loop Should I Use?
Situation
Best Loop
Repeat exactly 10 times
FOR 1 TO 10
Loop while password is wrong (check first)
WHILE
Ask for valid input (must run at least once)
REPEAT UNTIL
⚡ Exam Tip:REPEAT UNTIL is ideal for input validation — it guarantees the prompt is shown at least once.
Exam Practice
Have a go at this question
AQA-style question
Write a program using a REPEAT UNTIL loop that repeatedly asks the user to enter a password until they enter the correct password 'secret'. Output 'Access granted' when correct.