Skip to content

AQA GCSE · Free tool

AQA GCSE 8525 Pseudo-code Runner

Run AQA GCSE Computer Science 8525 pseudo-code online, exactly as it's written in AQA exams. Add inputs and see output and line-numbered errors. Free, no sign-up.

AQA 8525
main.aqa
Ready

8525 pseudo-code rules

AQA GCSE pseudo-code with zero-based arrays, SUBROUTINE blocks and USERINPUT.
  • Assign with ← (type <-); compare with =, ≠, <, ≤, >, ≥.
  • IF ... THEN ... ELSE IF ... ELSE ... ENDIF; FOR loops end with ENDFOR.
  • Arrays and strings start at index 0; LEN, POSITION and SUBSTRING(start, end, text).
  • Subroutines use SUBROUTINE ... ENDSUBROUTINE and may RETURN a value.

8525 example programs

Every example runs exactly as shown. Open one in the editor to change it and run it again.

Average until zero

Reads numbers with USERINPUT in a WHILE loop until the user enters 0, then outputs the average.

Input and outputLoops

Open in editor
# Average of the numbers entered (0 to stop)
total ← 0
count ← 0
OUTPUT 'Enter a number (0 to stop)'
number ← USERINPUT
WHILE number ≠ 0
  total ← total + number
  count ← count + 1
  number ← USERINPUT
ENDWHILE
IF count > 0 THEN
  OUTPUT 'Average: ', total / count
ELSE
  OUTPUT 'No numbers entered'
ENDIF
Inputs
8, 4, 6, 0
Output
Enter a number (0 to stop)
Average: 6

Grade boundaries

Uses IF ... ELSE IF ... ELSE with ≥ comparisons to turn a mark into a grade.

Selection

Open in editor
# Convert a mark into a grade
OUTPUT 'Enter a mark out of 100'
mark ← USERINPUT
IF mark ≥ 70 THEN
  grade ← 'A'
ELSE IF mark ≥ 50 THEN
  grade ← 'B'
ELSE IF mark ≥ 30 THEN
  grade ← 'C'
ELSE
  grade ← 'U'
ENDIF
OUTPUT 'Grade: ' + grade
Inputs
64
Output
Enter a mark out of 100
Grade: B

Subroutines and string handling

Splits a full name with POSITION and SUBSTRING and calls subroutines with and without RETURN.

SubroutinesStrings

Open in editor
# Subroutines and string handling
SUBROUTINE initials(first, last)
  RETURN SUBSTRING(0, 0, first) + SUBSTRING(0, 0, last)
ENDSUBROUTINE

SUBROUTINE shout(message)
  OUTPUT message + '!'
ENDSUBROUTINE

name ← 'Grace Hopper'
space ← POSITION(name, ' ')
first ← SUBSTRING(0, space - 1, name)
last ← SUBSTRING(space + 1, LEN(name) - 1, name)
OUTPUT initials(first, last)
shout('Hello ' + first)
Output
GH
Hello Grace!

Records

Defines a RECORD, creates records with the constructor and loops over them with FOR ... IN.

RecordsArrays

Open in editor
# Records and FOR ... IN
RECORD Pet
  name : String
  age : Integer
ENDRECORD

pets ← [Pet('Rex', 3), Pet('Tilly', 7)]
FOR p IN pets
  OUTPUT p.name + ' is ' + INT_TO_STRING(p.age)
ENDFOR
Output
Rex is 3
Tilly is 7

Rolling a dice

Uses RANDOM_INT inside REPEAT ... UNTIL to count how many rolls it takes to get a six.

Random numbersLoops

Open in editor
# Roll a dice until a six appears
rolls ← 0
REPEAT
  dice ← RANDOM_INT(1, 6)
  rolls ← rolls + 1
  OUTPUT 'Rolled a ' + INT_TO_STRING(dice)
UNTIL dice = 6
OUTPUT 'It took ' + INT_TO_STRING(rolls) + ' rolls to get a 6'