AQA · GCSE · Computer Science
Course version: 8525 · Version from Sept 2020
WHILE NotSolved … Instructions here ... FOR i ← 1 TO 5 … Instructions here…
Full specification wording
Programming concepts: WHILE NotSolved … Instructions here ... FOR i ← 1 TO 5 … Instructions here … ENDFOR … Instructions here … ENDWHILE
This pseudocode shows nested iteration: a FOR loop counting i from 1 to 5 sits inside a WHILE loop that continues while NotSolved is true.
Checked against the AQA 8525 specification (opens in a new tab) on .
- Point 19 of 23
Study notes
From the checked teaching notes for this specification point.
The idea
This pseudocode shows nested iteration: a FOR loop counting i from 1 to 5 sits inside a WHILE loop that continues while NotSolved is true. Trace it by working outwards. The WHILE condition is tested first; if NotSolved is true, the body runs. Inside, the FOR loop executes its instructions five times (i = 1, 2, 3, 4, 5), then the instructions after ENDFOR run once, then the WHILE condition is retested. So each WHILE pass performs five FOR passes plus the trailing instructions. The FOR loop restarts from i = 1 on every WHILE pass. The WHILE ends when NotSolved becomes false, which must happen inside the body or the loop never terminates.
What earns the marks
- Identifies the WHILE loop as the outer loop and the FOR loop as the inner loop.
- States that the FOR loop executes five times (i = 1 to 5) for each pass of the WHILE loop.
- Explains that the instructions after ENDFOR run once per WHILE pass, after the FOR loop completes.
- Recognises that the WHILE condition is retested after the body finishes and that NotSolved must change to end the loop.
- Notes that the FOR loop restarts from i = 1 on each new WHILE pass.
Common mistakes and how to put them right
Thinking the FOR loop runs only once in total.
Put it right: It restarts and runs five times on every WHILE pass.
Believing the trailing instructions run inside the FOR loop.
Put it right: They sit after ENDFOR, so they run once per WHILE pass.
Ignoring termination; correction: NotSolved must be set to false somewhere in the body or the WHILE never ends.
Exam tips
- Label the outer and inner loops before tracing any values.
- Track i through 1 to 5 for one WHILE pass, then note the loop resets.
- Check where NotSolved is updated to confirm the loop can terminate.
Try the lesson
The start of the Programming concepts: WHILE NotSolved … Instructions here ... FOR i ← 1 TO 5 … Instructions here … ENDFOR … Instructions here … ENDWHILE lesson, made from checked teaching notes for this specification point.
Have a go first
A program contains a FOR loop written as FOR i ← 1 TO 5. How many times will the instructions inside this FOR loop be executed?
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: WHILE NotSolved … Instructions here ... FOR i ← 1 TO 5 … Instructions here … ENDFOR … Instructions here … ENDWHILE
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