AQA · GCSE · Computer Science

    Course version: 8525 · Version from Sept 2020

    Programming concepts: DO … Instructions here … WHILE NotSolved

    A post-condition (post-test) loop runs its body first and only then tests the condition, so the instructions always execute at least once.

    Checked against the AQA 8525 specification (opens in a new tab) on .

    • Point 16 of 23

    Study notes

    From the checked teaching notes for this specification point.

    The idea

    A post-condition (post-test) loop runs its body first and only then tests the condition, so the instructions always execute at least once. In the pattern DO … Instructions here … WHILE NotSolved, the program performs the instructions, then evaluates NotSolved; if it is true the loop repeats, and if it is false the loop ends. This differs from a pre-condition loop such as WHILE NotSolved … ENDWHILE, which tests first and may skip the body entirely. A typical use is repeatedly asking for input until a valid value is entered, or repeating a game turn until the puzzle is solved. When answering, trace the order of execution: body, then test, then either repeat or exit.

    What earns the marks

    • Identifies the structure as a post-condition (post-test) loop because the condition is checked after the body runs.
    • States that the instructions execute at least once, even if the condition is false on the first test.
    • Explains that the loop repeats while NotSolved remains true and terminates when NotSolved becomes false.
    • Contrasts it with a pre-condition WHILE loop, which tests before the body and may run zero times.
    • Applies the pattern to a realistic case, such as repeating input until a valid value is entered.

    Common mistakes and how to put them right

    • Treating the loop as testing before the body runs.

      Put it right by noting the condition appears after the instructions, so the body always runs at least once.

    • Assuming the loop stops when NotSolved is true.

      Put it right by stating it continues while NotSolved is true and stops when it is false.

    • Confusing this with a FOR loop that repeats a fixed number of times.

      Put it right by explaining the repetition depends on a condition, not a counter.

    Exam tips

    • Underline where the condition sits in the code before deciding whether it is pre-test or post-test.
    • Trace a short example with two or three passes, writing the value of NotSolved after each test.
    • When comparing loop types, state clearly which one guarantees at least one execution.

    Try the lesson

    The start of the Programming concepts: DO … Instructions here … WHILE NotSolved lesson, made from checked teaching notes for this specification point.

    Have a go first

    In a DO … WHILE NotSolved loop, what does the loop do while NotSolved is true?

    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.

    Carry on with the full lesson

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge

    Test your understanding of Programming concepts: DO … Instructions here … WHILE NotSolved

    Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.

    Take topic quiz

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge