Edexcel Pseudocode 1
Edexcel Pseudocode 1
Questions in the written examination that involve code will use this pseudo-code for clarity and
consistency. However, students may answer questions using any valid method.
Data types
INTEGER
REAL
BOOLEAN
CHARACTER
Type coercion
Type coercion is automatic if indicated by context. For example 3 + 8.25 = 11.25
(integer + real = real)
INTEGER REAL
Coercion can be made explicit. For example, RECEIVE age FROM (INTEGER) KEYBOARD assumes
that the input from the keyboard is interpreted as an INTEGER, not a STRING.
Constants
The value of constants can only ever be set once. They are identified by the keyword CONST.
Two examples of using a constant are shown.
CONST REAL PI
SET PI TO 3.14159
Data structures
ARRAY
STRING
Using & with a STRING and a non-STRING will coerce to STRING. For example, SEND `Fred’ & age
TO DISPLAY, will display a single STRING of `Fred18’.
Functions
LENGTH()
RANDOM(n)
Comments
Comments are indicated by the # symbol, followed by any text.
Devices
Use of KEYBOARD and DISPLAY are suitable for input and output.
Additional devices may be required, but their function will be obvious from the context. For
example, CARD_READER and MOTOR are two such devices.
Notes
In the following pseudo-code, the < > indicates where expressions or values need to be supplied.
The < > symbols are not part of the pseudo-code.
SET Counter TO 0
SET Variable TO <value> Assigns a value to a variable.
SET MyString TO ‘Hello world’
REPEAT <expression> TIMES Count controlled loop. The number of times REPEAT 100-Number TIMES
<command> <command> is executed is determined by the SEND ‘*’ TO DISPLAY
END REPEAT expression. END REPEAT
SEND <expression> TO DISPLAY Sends output to the screen. SEND ‘Have a good day.’ TO DISPLAY
File handling
Symbol Description
+ Add
- Subtract
/ Divide
* Multiply
^ Exponent
MOD Modulo
Relational operators
Symbol Description
= equal to
Logical operators
Symbol Description
AND Returns true if both conditions
are true.