📄 Paper 1 · 4.1 Fundamentals of Programming
⭐ Pro
4.1.1b Sequence, Selection & Iteration
AQA 7517 · A-Level Computer Science · ~15 min read

Programming Constructs — Overview

All programs are built using three fundamental constructs. AQA 7517 requires you to use all three correctly in pseudocode and understand how they control program flow.

1. Sequence

Sequence is the default mode of execution — statements execute one after another, in the order they are written, from top to bottom. No branching or repeating occurs.

DECLARE total : INTEGER
total ← 0
total ← total + 10
OUTPUT total      ← outputs 10

Every program has sequence as its base. The other two constructs interrupt or repeat parts of the sequence.

2. Selection

Selection allows a program to make decisions — different code paths execute depending on whether a condition is True or False.

IF … THEN … ELSE … ENDIF

IF score >= 70 THEN
    OUTPUT "Pass"
ELSE
    OUTPUT "Fail"
ENDIF

ELSE IF (Nested Selection)

IF score >= 90 THEN
    grade ← "A"
ELSE IF score >= 70 THEN
    grade ← "B"
ELSE IF score >= 50 THEN
    grade ← "C"
ELSE
    grade ← "F"
ENDIF

CASE … OF … OTHERWISE … ENDCASE (Switch Statement)

Used when a single variable or expression is compared against multiple fixed values — cleaner than many ELSE IFs:

CASE OF day
    1: OUTPUT "Monday"
    2: OUTPUT "Tuesday"
    3: OUTPUT "Wednesday"
    OTHERWISE: OUTPUT "Invalid"
ENDCASE
Exam tip: AQA uses CASE OF — not SWITCH. Always use the correct AQA pseudocode keyword. CASE cannot test ranges — it matches exact values only.

3. Iteration

Iteration (looping) repeats a block of code. AQA 7517 requires three loop types:

FOR Loop — Count-controlled

Use when the number of repetitions is known in advance.

FOR i ← 1 TO 10
    OUTPUT i
NEXT i

WHILE Loop — Pre-condition (condition tested before each iteration)

Use when the number of iterations is unknown and the condition is checked before the body executes — the loop may not execute at all if the condition is initially False.

WHILE answer ≠ "quit" DO
    INPUT answer
ENDWHILE

REPEAT … UNTIL — Post-condition (condition tested after each iteration)

The loop body always executes at least once — the condition is tested after the body.

REPEAT
    INPUT score
UNTIL score >= 0 AND score <= 100
Loop TypeCondition checkMinimum executionsUse case
FORCount-controlled0 (if TO < FROM)Known number of iterations
WHILEPre-condition0 (may never run)Unknown iterations; may not need to run
REPEAT … UNTILPost-condition1 (always runs once)Must run at least once; input validation

Nested Loops

Loops can be placed inside other loops. The inner loop completes fully for each iteration of the outer loop. Total iterations = outer iterations × inner iterations.

FOR row ← 1 TO 3
    FOR col ← 1 TO 4
        OUTPUT row * col
    NEXT col
NEXT row
← Outputs 3 × 4 = 12 values
⚠️ Common Mistakes
  • Using WHILE when REPEAT…UNTIL is needed (e.g. for input validation that must run at least once)
  • Off-by-one errors in FOR loops — FOR i ← 1 TO 10 runs 10 times (i=1,2,...,10), not 9
  • Forgetting NEXT i or ENDWHILE / ENDIF — losing marks in exam answers
  • Using CASE for range comparisons — CASE only matches exact values, use nested IF for ranges
  • Writing pseudo-Python instead of AQA pseudocode — e.g. writing if instead of IF
Video coming soon
Click through the slides at your own pace. Use arrow keys or click to advance.
Click slide or press arrow keys to navigate

Worksheet — 4.1.1b Sequence, Selection & Iteration

8 questions · instantly marked · AQA 7517 standard

Q1State the three fundamental programming constructs and briefly describe each.[3]
✅ Mark scheme
Mark scheme
Sequence — statements execute one after another in order [1]; Selection — a choice between two or more code paths based on a condition [1]; Iteration — repetition of a block of code [1].
Q2Write AQA pseudocode using a CASE statement that outputs the name of the day for the values 1–7 (1=Monday … 7=Sunday), and "Invalid" for any other value.[4]
✅ Mark scheme
Mark scheme
CASE OF day [1]; at least four correct day–number mappings [1]; OTHERWISE with "Invalid" [1]; ENDCASE [1]. Award [3] max if overall structure correct but minor pseudocode errors.
Q3Explain the difference between a WHILE loop and a REPEAT…UNTIL loop, including which executes at least once.[3]
✅ Mark scheme
Mark scheme
WHILE checks condition before each iteration — if condition is initially False, loop body never executes [1]; REPEAT…UNTIL checks condition after — loop body always executes at least once [1]; REPEAT…UNTIL continues while condition is False, stopping when it becomes True [1].
Q4Write AQA pseudocode using a REPEAT…UNTIL loop that asks the user to enter a number between 1 and 10 inclusive, repeating until a valid number is entered.[3]
✅ Mark scheme
Mark scheme
REPEAT [1]; INPUT num (or equivalent prompt) [1]; UNTIL num >= 1 AND num <= 10 [1]. Accept equivalent valid pseudocode with correct structure.
Q5A FOR loop is written: FOR i ← 1 TO 5. How many times does the loop body execute? What is the value of i at the end of the last iteration?[2]
✅ Mark scheme
Mark scheme
The loop body executes 5 times [1]; the value of i at the end of the last iteration is 5 [1].
Q6Write AQA pseudocode that uses nested FOR loops to print a 4×4 multiplication table (i.e. outputs row*col for each combination of row 1–4 and col 1–4).[4]
✅ Mark scheme
Mark scheme
Outer FOR row ← 1 TO 4 [1]; inner FOR col ← 1 TO 4 [1]; OUTPUT row * col (or equivalent) [1]; correct NEXT for both loops [1].
Q7Justify why REPEAT…UNTIL is more suitable than WHILE for validating user input when at least one attempt is always required.[2]
✅ Mark scheme
Mark scheme
REPEAT…UNTIL guarantees the loop body executes at least once [1], which is necessary since the user must be asked for input before the value can be checked [1]. With WHILE, if the condition were False before the first check, the loop would never run (though this wouldn't happen here as no value exists yet).
Q8Explain, with an example, why CASE OF cannot be used for range-based comparisons, and which construct should be used instead.[3]
✅ Mark scheme
Mark scheme
CASE OF matches only specific (discrete) values — it cannot evaluate conditions such as score >= 70 [1]; for example, grading (A if 90–100, B if 70–89 etc.) cannot use CASE because the cases are ranges, not single values [1]; nested IF…ELSE IF should be used instead [1].
Topic Quiz
Question 1 of 15
You scored
out of 15
Card 1 of 12
Click to reveal definition
🎉
All cards reviewed!
TermDefinition
🎯

Mini Test — Sequence, Selection & Iteration

10 questions · 10 marks · 10 minutes

← 4.1.1a Data Types
2 of 70 · AQA 7517
4.1.1c Arithmetic & Boolean Ops →