Track progress, take quizzes and save notes on this lesson.

Free forever · no card needed

Start free
Intermediate

Writing Exam-Style Programs

Support lesson — programming skills

Aligned to the AQA 8525 specification

Level
Intermediate
Reading time
6 min
Published
9 June 2026
Updated
1 July 2026
On this page
  1. 1.Why Integration Is Hard
  2. 2.Step 1: Plan Before You Write
  3. 3.Step 2: Write the Program
  4. 4.Step 3: Trace and Check
  5. 5.The Most Common Paper 1 Errors
  6. 6.Adapting This Pattern to Any Scenario

Key takeaways

  • Paper 1 questions combine variables, selection, iteration, arrays and subroutines in one program, so this lesson shows how to integrate concepts you already know rather than introducing new ones.
  • Always plan before writing using inputs, processing, outputs (IPO), then list the constructs you need; this avoids reaching the end and realising you forgot validation or used the wrong loop type.
  • Use a FOR loop when the number of iterations is known in advance and a WHILE loop when you repeat until a condition changes, such as validating input until it is acceptable.
  • Verify a finished program with a trace table, using a test case that exercises the validation (an invalid input followed by a valid one) and checks each output branch.
  • Use a FUNCTION when a value needs to be returned and a SUBROUTINE for actions; a SUBROUTINE cannot return a value with RETURN.

Why Integration Is Hard

The programming spec is taught topic by topic — variables, then selection, then iteration, then arrays, then subroutines. But Paper 1 exam questions do not arrive topic by topic. A question might ask you to write a program that uses all of those things together, in a single coherent solution.

This lesson does not introduce new programming concepts. It shows you how to pull everything you already know into a complete program — the way the exam requires you to.

Step 1: Plan Before You Write

The biggest Paper 1 mistake is writing code immediately. Students who plan first write cleaner, more complete programs and make fewer errors.

Always start with inputs, processing, outputs (IPO):

Scenario: Write a program that asks a user to enter 5 quiz scores (each between 0 and 10), validates each score, stores them, calculates the average, and tells the user whether they passed (average ≥ 6) or failed.

ComponentDetail
Inputs5 quiz scores, each entered by the user
ProcessingValidate each score (range 0–10); store in array; sum all scores; calculate average
OutputEach invalid score rejected with a message; final average; "Pass" or "Fail"

What programming constructs do I need?

  • Array to store 5 scores
  • FOR loop to collect 5 inputs
  • WHILE loop (inside FOR) for validation
  • Accumulator to total the scores
  • IF/ELSE for pass/fail decision
  • FUNCTION to keep validation reusable

Planning this before writing means you will not reach the end and realise you forgot validation, or used the wrong loop type.

Step 2: Write the Program

With the plan in hand, build the solution piece by piece.

Pseudocode:

FUNCTION getValidScore()
    OUTPUT "Enter score (0-10): "
    score ← INT(USERINPUT)
    WHILE score < 0 OR score > 10 DO
        OUTPUT "Invalid. Enter a score between 0 and 10: "
        score ← INT(USERINPUT)
    ENDWHILE
    RETURN score
ENDFUNCTION

SUBROUTINE runQuiz()
    scores ← [0, 0, 0, 0, 0]
    total ← 0

    FOR i ← 0 TO 4
        scores[i] ← getValidScore()
        total ← total + scores[i]
    NEXT i

    average ← total / 5

    OUTPUT "Your average score is: " & STR(average)

    IF average ≥ 6 THEN
        OUTPUT "Pass"
    ELSE
        OUTPUT "Fail"
    ENDIF
ENDSUBROUTINE

runQuiz()

Python equivalent:

def get_valid_score():
    score = int(input("Enter score (0-10): "))
    while score < 0 or score > 10:
        print("Invalid. Enter a score between 0 and 10.")
        score = int(input("Enter score (0-10): "))
    return score

def run_quiz():
    scores = [0] * 5
    total = 0

    for i in range(5):
        scores[i] = get_valid_score()
        total += scores[i]

    average = total / 5
    print(f"Your average score is: {average}")

    if average >= 6:
        print("Pass")
    else:
        print("Fail")

run_quiz()

Step 3: Trace and Check

Once written, verify the program with a trace table. Use a test case that exercises the validation (an invalid input followed by a valid one) and checks the pass/fail branch.

Test: inputs are 10, 8, 7, 6, 9 — all valid, average = 8.0, expect Pass.

iscore enteredvalid?scores[i]total after
0101010
18818
27725
36631
49940

average = 40 / 5 = 8.0 → 8.0 ≥ 6 → Output: "Pass" ✓

Test: one invalid input — user enters 15, then 8.

AttemptInputCondition: 15 < 0 OR 15 > 10Action
115TRUEReject, ask again
28FALSEAccept, exit WHILE

score returned = 8 ✓

Want more lessons like this one?

Generate lessons on anything you study. Free account, no card needed.

Start generating

The Most Common Paper 1 Errors

These errors appear in student answers repeatedly. Check your program against every item before you stop writing.

1. Uninitialised variables

# Wrong — total has no starting value
FOR i ← 0 TO 4
    total ← total + scores[i]
NEXT i
# Correct
total ← 0
FOR i ← 0 TO 4
    total ← total + scores[i]
NEXT i

Using a variable before assigning it a value is a logic error that produces unpredictable results.

2. Missing ENDIF or ENDWHILE

# Wrong
IF average ≥ 6 THEN
    OUTPUT "Pass"
ELSE
    OUTPUT "Fail"
# Missing ENDIF — syntax error, program cannot run

Every IF needs ENDIF. Every WHILE needs ENDWHILE. Every FOR needs NEXT. Check these before finishing.

3. Wrong loop type

  • FOR — use when you know the exact number of iterations in advance (e.g. "collect 5 scores")
  • WHILE — use when you repeat until a condition changes (e.g. "keep asking until valid")

Using a FOR loop for validation forces a fixed number of attempts. Using a WHILE loop to collect exactly 5 scores makes the count harder to control. Match the loop type to the problem.

4. Array index errors

AQA pseudocode arrays are zero-indexed by convention in most contexts. A 5-element array uses indices 0 to 4. A FOR loop to fill it should run FOR i ← 0 TO 4, not 1 TO 5.

5. No validation on user input

If the question describes a range or constraint on input, validate it. An unvalidated input that accepts any value — including impossible ones — is an incomplete answer for any question that asks for a "robust" or "secure" program.

6. Using SUBROUTINE when a value needs to be returned

A SUBROUTINE performs actions but does not return a value. A FUNCTION calculates and returns a value with RETURN. If your code needs to use the result of a called block elsewhere, it must be a FUNCTION.

# Wrong — SUBROUTINE cannot be used to return a value
SUBROUTINE getValidScore()
    ...
    RETURN score   # invalid in a SUBROUTINE
ENDSUBROUTINE

# Correct
FUNCTION getValidScore()
    ...
    RETURN score
ENDFUNCTION

7. Vague identifier names

x, a, temp tell the examiner nothing. Use names that reflect the variable's purpose: score, total, average, userName. Clear identifiers also reduce your own mistakes.

Adapting This Pattern to Any Scenario

The program in this lesson follows a pattern you can adapt to almost any Paper 1 question:

  1. Define a FUNCTION to get and validate a single piece of input
  2. Use a FOR loop to collect the required number of inputs into an array
  3. Process the array (total, count, find max/min, search, sort)
  4. Output results using IF/ELSE or OUTPUT statements
  5. Wrap in a SUBROUTINE called at the end

Not every question needs every component. But thinking in this structure before writing means you will not forget validation, will not use the wrong loop, and will not miss an ENDIF.

Frequently asked questions

Plan before you write. Start by listing the inputs, processing and outputs (IPO), then identify the programming constructs you need, such as arrays, loops and functions. Build the solution piece by piece, then verify it with a trace table before you stop writing.

Use a FOR loop when you know the exact number of iterations in advance, for example collecting 5 scores. Use a WHILE loop when you repeat until a condition changes, such as validating input by asking again until the value is acceptable. Match the loop type to the problem.

Common errors include uninitialised variables, missing ENDIF, ENDWHILE or NEXT, using the wrong loop type, array index errors, missing input validation, using a SUBROUTINE where a value must be returned, and vague identifier names like x or temp.

Generate revision on any topic you study

Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.

Lessons on anything

Structured, level-matched lessons on any topic you study

Practice quizzes

Find out what you actually know before the exam does

Flashcard sets

Lock in key concepts with instant revision cards

Ask Aica

Stuck on something? Get a clear explanation, any time

Prev

Logic Gates to Circuits: Worked Practice

Related lessons

Top students don’t revise more. They revise what counts.

Start revising free

Free to start. No card needed.