Skip to main content
EnglandComputer ScienceSyllabus dot point

How do we control the order in which a program's instructions run?

Use the three programming constructs of sequence, selection and iteration, including definite and indefinite iteration, and nest them.

A focused answer to AQA GCSE Computer Science 3.2.2, covering the three programming constructs of sequence, selection and iteration, the difference between definite and indefinite iteration, and nesting.

Generated by Claude Opus 4.88 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. Sequence
  3. Selection
  4. Iteration
  5. Nesting
  6. Choosing the right loop
  7. Try this

What this dot point is asking

AQA wants you to use the three programming constructs (sequence, selection and iteration), to tell definite iteration from indefinite iteration, and to nest constructs inside one another.

Sequence

Selection

IF age >= 18 THEN
    OUTPUT 'adult'
ELSE
    OUTPUT 'child'
ENDIF

A CASE (or SWITCH) statement is convenient when one variable is tested against many possible values, avoiding a long chain of IF/ELSE.

Iteration

A WHILE loop tests its condition before the body, so it can run zero times if the condition is false at the start. A REPEAT UNTIL loop tests after the body, so it always runs at least once. This difference decides which to use: count-controlled tasks use FOR, condition-controlled tasks use WHILE, and tasks needing at least one run (such as input validation) use REPEAT UNTIL.

FOR i <- 1 TO 5
    OUTPUT i
ENDFOR

Nesting

Choosing the right loop

Picking the correct loop is a common exam decision. Use a FOR loop when you know in advance how many times to repeat, such as processing every element of an array of known length or printing a times table. Use a WHILE loop when the number of repetitions depends on a condition that might be false from the start, such as "while there is more input" or "while the guess is wrong", because the body may need to run zero times. Use a REPEAT UNTIL loop when the body must run at least once before the condition can be tested, the classic case being input validation, where you must ask for the input before you can check it. Justifying the choice with this reasoning is what earns marks on "which loop and why" questions.

Try this

Q1. Name the three programming constructs. [3 marks]

  • Cue. Sequence, selection and iteration.

Q2. State one difference between a WHILE loop and a REPEAT UNTIL loop. [2 marks]

  • Cue. A WHILE loop tests the condition before the body so can run zero times; a REPEAT UNTIL loop tests after the body so always runs at least once.

Exam-style practice questions

Practice questions written in the style of AQA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

AQA 20195 marksWrite AQA-style pseudocode that uses a count-controlled loop to output the 7 times table from 7 x 1 to 7 x 12. Identify which programming constructs you have used.
Show worked answer →

A correct solution uses a definite (count-controlled) loop:

FOR i <- 1 TO 12
OUTPUT 7 * i
ENDFOR

Constructs used: iteration (the FOR loop) and sequence (the statements run in order). The loop is definite iteration because the number of repetitions (12) is known in advance.

Markers reward the correct loop bounds (1 to 12), outputting 7 * i, the closing ENDFOR, and naming iteration and sequence (and stating it is definite iteration).

AQA 20214 marksExplain the difference between a WHILE loop and a REPEAT UNTIL loop, and state which you would use to validate that a user enters a number greater than 0, justifying your choice.
Show worked answer →

A WHILE loop tests its condition before the body runs, so the body may run zero times if the condition is false at the start. A REPEAT UNTIL loop tests its condition after the body, so the body always runs at least once.

For input validation you would use a REPEAT UNTIL loop, because you must ask for the input at least once before you can test it. The loop repeats the prompt and input until the value is greater than 0.

Markers reward the before-versus-after test distinction, the zero-times versus at-least-once consequence, and a justified choice of REPEAT UNTIL for validation.

Related dot points

Sources & how we know this