Selection in pseudocode lets an algorithm choose between different paths based on a condition. Written with IF, ELSE, and ELSE IF (or ELIF), it is one of the three fundamental programming constructs — sequence, selection, and iteration — and appears in nearly every GCSE exam answer involving algorithms.

What is selection and why is it one of the three fundamental constructs?

Every algorithm is built from three building blocks:

Construct What it does Pseudocode keyword
Sequence Instructions executed one after another in order (no keyword — just list them)
Selection A branch — one path taken based on a condition IF, ELSE IF, ELSE
Iteration Repetition — a block repeated while a condition holds WHILE, FOR

These three constructs are sufficient to express any algorithm — a foundational result in computer science. Selection is what gives an algorithm the power to make decisions: to do one thing if a condition is true, and something different if it is false.

How do you write a simple IF statement in pseudocode?

The basic form tests one condition:

IF condition THEN
    statements
END IF

Worked example — checking whether a score is a pass:

score ← INPUT("Enter your score: ")

IF score >= 50 THEN
    OUTPUT "You have passed."
END IF

If score is 60, the condition score >= 50 is TRUE and the OUTPUT runs. If score is 40, the condition is FALSE and the OUTPUT is skipped — the program moves to the line after END IF.

How do you add an ELSE clause?

An ELSE clause handles the case when the IF condition is FALSE:

IF condition THEN
    statements for when condition is TRUE
ELSE
    statements for when condition is FALSE
END IF

Example:

IF score >= 50 THEN
    OUTPUT "Pass"
ELSE
    OUTPUT "Fail"
END IF

Now one of the two OUTPUT statements always runs — there is no case where neither branch executes. This is important: every meaningful IF/ELSE covers all possibilities.

How do you add ELSE IF for multiple conditions?

When there are more than two outcomes, chain additional conditions with ELSE IF:

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

Python equivalent for comparison:

if score >= 70:
    print("Distinction")
elif score >= 50:
    print("Merit")
elif score >= 40:
    print("Pass")
else:
    print("Fail")

The conditions are tested from top to bottom. The first one that is TRUE wins; subsequent conditions are skipped. This means the order of ELSE IF clauses matters: if you put score >= 40 first, a score of 80 would incorrectly output "Pass".

How do you write nested selection?

A nested IF is an IF statement placed inside another IF or ELSE block:

IF age >= 18 THEN
    IF has_id = TRUE THEN
        OUTPUT "Entry permitted"
    ELSE
        OUTPUT "ID required"
    END IF
ELSE
    OUTPUT "Under 18: entry denied"
END IF

Nested selection is used when a second condition only makes sense if the first one is already TRUE. In this example, checking for ID is only relevant if the person is already old enough.

Indentation is critical in pseudocode — it shows which END IF belongs to which IF. Misaligned indentation is a common error in GCSE answers.

What are the most common selection mistakes in pseudocode?

Mistake Example Correction
Missing THEN keyword IF score >= 50 IF score >= 50 THEN
Missing END IF Block left open Every IF must have exactly one END IF
Wrong comparison operator IF score = 50 (assignment) IF score == 50 THEN or IF score = 50 THEN (depends on board)
ELSE IF order wrong Larger boundary checked last Check tightest/largest first
Nested indent wrong END IF at wrong level Each END IF closes the nearest open IF

Different exam boards have slightly different pseudocode conventions. AQA uses IF … THEN … ELSE IF … ELSE … END IF. OCR uses a similar structure. Always check your specific board's reference sheet — but the logical structure is identical across all boards.

Frequently asked questions

Does pseudocode need to be exactly right syntactically to gain marks?

No — pseudocode is marked on whether the logic is correct, not whether it follows a specific syntax to the letter. Examiners apply "benefit of the doubt" to minor notation differences (e.g. ELSEIF vs ELSE IF). However, the logic must be unambiguous: conditions must be correct, END IF statements must close the right blocks, and indentation should clearly show nesting. A mark scheme typically asks whether a reader could implement the pseudocode correctly.

What is the difference between = and == in pseudocode?

This varies by exam board. In Python, = assigns a value and == compares. AQA's pseudocode uses = for both assignment (with preferred for assignment) and comparison, while the context makes the meaning clear. OCR uses = for comparison in conditions. In an exam, use whatever your board's reference sheet shows, and be consistent.

Can you have an IF statement without an ELSE?

Yes. A bare IF … END IF (with no ELSE) is valid. The ELSE branch is optional — you only include it when you want specific code to run when the condition is FALSE. If there is nothing to do in the FALSE case, simply omit the ELSE and the algorithm continues to the line after END IF.

When should you use nested IFs versus ELSE IF?

Use ELSE IF when conditions are mutually exclusive alternatives for the same variable (e.g. different score ranges). Use nested IFs when a second question only makes sense after the first condition is confirmed TRUE (e.g. first check age, then check ID). Nested IFs for mutually exclusive alternatives create unnecessary complexity; ELSE IF chains are cleaner and easier to read.


Practise writing pseudocode selection structures with step-by-step feedback from Professor Turing at aitutors.me.