Pseudocode is English-like, structured notation used to plan algorithms before writing them in a real programming language. This guide shows you how to write it correctly for GCSE Computer Science exams — covering variables, input/output, selection, loops, and subroutines with the exact conventions most boards expect.

Step 1 — Understand what pseudocode is for

Pseudocode sits between a flowchart and actual code. It is precise enough to show the logic of an algorithm, but flexible enough that you do not need to worry about language-specific syntax (colons, brackets, capitalisation rules). In a GCSE exam, pseudocode answers are marked on logic correctness, not on exact syntax — but using consistent, recognisable conventions will earn full marks.

A good test: could a programmer read your pseudocode and implement it in any programming language without needing to ask you questions? If yes, it is well-written pseudocode.

Step 2 — Declare and assign variables

Use (the assignment arrow) or = to assign values. Name variables in camelCase or with underscores — no spaces:

score ← 0
playerName ← "Amara"
lives ← 3
isRunning ← TRUE

Most GCSE boards use for assignment to visually distinguish it from the equality comparison =. Some boards accept = for both — check your specification's reference sheet.

Step 3 — Write input and output

Use INPUT and OUTPUT (or PRINT):

OUTPUT "Enter your name: "
name ← INPUT()

OUTPUT "Enter your score: "
score ← INPUT()

Some boards write name ← USERINPUT or name ← INPUT("Enter your name: "). Both are acceptable as long as the intent is clear. Always output something meaningful to the user — a bare INPUT() with no prompt is poor practice.

Step 4 — Write selection (IF statements)

IF score >= 70 THEN
    OUTPUT "Distinction"
ELSE IF score >= 50 THEN
    OUTPUT "Merit"
ELSE IF score >= 40 THEN
    OUTPUT "Pass"
ELSE
    OUTPUT "Fail"
END IF

Rules:

  • Every IF must have a matching END IF.
  • Use THEN after the condition.
  • Indent the body consistently (use 4 spaces or a clear tab equivalent).
  • Test conditions from the most restrictive to the least restrictive (largest threshold first).

Step 5 — Write iteration (loops)

WHILE loop — runs while a condition is true:

count ← 0
WHILE count < 10
    OUTPUT count
    count ← count + 1
END WHILE

FOR loop — runs a fixed number of times:

FOR i ← 1 TO 10
    OUTPUT i * i
END FOR

FOR loop over an array:

FOR i ← 0 TO LENGTH(scores) - 1
    OUTPUT scores[i]
END FOR

Choose WHILE when the number of iterations is not known in advance. Choose FOR when it is known (a fixed count or array traversal).

Step 6 — Write subroutines (procedures and functions)

A procedure performs a task; a function returns a value.

FUNCTION calculateArea(width, height)
    area ← width * height
    RETURN area
END FUNCTION

PROCEDURE displayResult(area)
    OUTPUT "The area is: " + STR(area)
END PROCEDURE

# Calling them:
result ← calculateArea(5, 3)
displayResult(result)

Key conventions:

  • FUNCTIONRETURNEND FUNCTION for functions that return a value.
  • PROCEDUREEND PROCEDURE for procedures that do not return a value.
  • Pass values in via parameters; do not rely on global variables.

Step 7 — Work through a complete example

Problem: write pseudocode for a number-guessing game that picks a random number 1–10 and lets the user guess until correct.

secret ← RANDOM(1, 10)
guess ← 0
attempts ← 0

WHILE guess ≠ secret
    OUTPUT "Guess a number between 1 and 10: "
    guess ← INPUT()
    attempts ← attempts + 1

    IF guess < secret THEN
        OUTPUT "Too low!"
    ELSE IF guess > secret THEN
        OUTPUT "Too high!"
    END IF
END WHILE

OUTPUT "Correct! You took " + STR(attempts) + " attempts."

This example uses all five constructs: variable assignment, input/output, selection (IF/ELSE IF), iteration (WHILE), and string concatenation. Cover all five constructs in exam answers and you demonstrate the full breadth of algorithm design.

Frequently asked questions

Is pseudocode marked as right or wrong in GCSE, or is it assessed for logic?

Logic is what is marked. The mark scheme for a pseudocode question awards marks for correct logical steps — the right conditions, the right loop type, correct use of variables — not for following a specific notation exactly. Examiners apply "follow-through" marking: if you make a notational slip (e.g. writing ENDIF instead of END IF) but the logic is correct, you will not lose marks for the notation. However, using consistent conventions avoids ambiguity and makes marking easier.

Do I need to write pseudocode exactly as my exam board specifies?

You should follow your board's conventions as closely as possible, particularly for operators and keywords. AQA provides a pseudocode guide in its specification; OCR provides a similar reference. Both are available in the exam insert. In practice, mixing Python-style indentation with pseudocode keywords is widely accepted, as long as the logic is clear.

When should I use pseudocode rather than a flowchart?

Use pseudocode when the algorithm is complex — it handles nested conditions and loops more naturally than flowcharts, and it is faster to write in an exam. Use a flowchart when the question asks specifically for one, or when you want to show the overall flow at a high level (few branches, simple logic). Many GCSE questions accept either, so default to pseudocode unless instructed otherwise.

Does pseudocode need to handle errors (e.g. bad user input)?

In a GCSE exam answer, include error handling only if the question asks for it (e.g. "make the program robust"). For a basic algorithm question, a clean, correct main path is sufficient. In your programming project, however, robust input validation and error handling are expected and will earn marks in the testing and refinement criteria.


Write cleaner algorithms and pseudocode faster with personalised guidance from Professor Turing at aitutors.me.