AQA Pseudocode Specification
AQA Pseudocode Specification
The pseudo code described below is a teaching aid for schools/colleges to assist in preparing their students for Unit 2 (examined component) of AQA’s GCSE Computer
Science. Schools/colleges are free to use any methods they feel appropriate for teaching algorithm design.
Questions in the written examination that involve code will use this pseudo code for clarity and consistency. However, students may answer these questions in any valid format.
This document will be updated as required and the latest version will always be available on e-AQA. The version for use in the following summer exam will be published no later
than 1st September.
Updates will not usually be made during an academic year. If a revised version is published, AQA will inform schools/colleges.
=, ≠, ≤, ≥, <, > Binary comparison operators (note # see the examples for IF, IF-ELSE # and WHILE
that = is equality, not assignment).
Length
LEN(var) Function that returns integer value myVar ← [1, 2, 3, 4]
that is length of an array or a string varLen ← LEN(myVar)
# varLen is 4
str ← “hi”
strLen ← LEN(str)
# strLen is 2
line2 ← READLINE(fruit.txt, 2)
# line2 is “L2 banana”
WRITELINE(file, n, value) (Over)Writes the nth line of file with # using contents of fruit.txt from
value. If n exceeds the previous line # previous example:
numbers of file plus one then the gap
is filled with blank lines. newfruit ← “L4 dragonfruit”
WRITELINE(fruit.txt, 4, newfruit)
WRITELINE(fruit.txt, 2, “empty”)
greeting ← ”hello”
OUTPUT “hi”
# outputs “hi”
OUTPUT greeting
# outputs “hello”
USERINPUT Waits for human input and then can answer ← USERINPUT
assign this value.
Copyright © 2012 AQA and its licensors. All rights reserved.
The Assessment and Qualifications Alliance (AQA) is a company limited by guarantee registered in England and Wales (company number 3644723)
and a registered charity (registered charity number 1073334). Registered address: AQA, Devas Street, Manchester M15 6EX
Syntax Meaning Example
Expressions and statements used in the examples
iexp An integer expression 4
6 / 4
43 MOD 2
LEN(myArr)
bexp A Boolean expression true
false
NOT a
(a OR b) AND (NOT a)
var, pname, fname Any sensible name for the variable, # see examples above
procedure or function respectively.
Assume that all names will be unique.
statements A (possibly empty) series of one line # three statements:
statements. A statement is a ← 43
terminated by a new line. b ← 16
c ← a + b