AQA · GCSE · Computer Science
Course version: 8525 · Version from Sept 2020
Programming concepts: iteration
Iteration means repeating a block of code instead of writing it out many times.
Checked against the AQA 8525 specification (opens in a new tab) on .
- Point 5 of 23
Study notes
From the checked teaching notes for this specification point.
The idea
Iteration means repeating a block of code instead of writing it out many times. Count-controlled iteration repeats a known number of times, typically with a FOR loop that uses a counter and a stopping value. Condition-controlled iteration repeats according to a test: a WHILE loop checks its condition before each pass and continues while the condition is true, so it may run zero times; a REPEAT...UNTIL loop runs its body first and then repeats until its condition becomes true, so it always runs at least once. Choosing the right loop depends on whether the number of repetitions is known in advance and whether the body must run at least once.
What earns the marks
- Count-controlled iteration (FOR) repeats a known number of times using a counter and a stopping value.
- Condition-controlled iteration repeats according to a Boolean condition tested by the loop.
- A WHILE loop tests before each pass and continues while its condition is true, so it can execute zero times.
- A REPEAT...UNTIL loop executes its body first and repeats until its condition becomes true, so it always executes at least once.
- Selecting a loop depends on whether the repetition count is known and whether the body must run at least once.
Common mistakes and how to put them right
Saying a REPEAT...UNTIL loop continues while its condition is true.
Put it right: It repeats until the condition becomes true, so it stops when the condition is true.
Assuming a WHILE loop always runs at least once.
Put it right: It tests first, so a false condition at the start means zero passes.
Confusing iteration with selection.
Put it right: Iteration repeats code, whereas selection chooses between alternative paths.
Exam tips
- Identify from the question whether the number of repetitions is fixed; if so, a FOR loop is usually appropriate.
- Check whether the body must run at least once; if so, prefer REPEAT...UNTIL over WHILE.
- Trace a short loop by hand, writing the value of the condition after each pass, to confirm how many times it runs.
Try the lesson
The start of the Programming concepts: iteration lesson, made from checked teaching notes for this specification point.
Have a go first
A program needs to display the numbers 1 to 5 on separate lines. Which type of construct is most appropriate for repeating the display instruction five times?
There is more to this lesson
The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge
Test your understanding of Programming concepts: iteration
Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge