Skip to content

AQA A Level · Free tool

AQA A Level 7517 Pseudo-code Runner

Run AQA A Level Computer Science 7517 pseudo-code online, with subroutines, arrays and string handling. Free, in your browser, no sign-up.

AQA 7517
main.aqa
Ready

7517 pseudo-code rules

AQA A Level pseudo-code for algorithms such as searching, sorting, recursion and stacks.
  • Assign with ← (type <-); constants use CONSTANT NAME = value.
  • Zero-based arrays created with lists, e.g. items ← [3, 8, 15].
  • SUBROUTINE blocks that RETURN a value act as functions.
  • DIV and MOD are written between values, e.g. (low + high) DIV 2.

7517 example programs

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

Recursive Fibonacci

A recursive SUBROUTINE with a base case generates the first eleven Fibonacci numbers.

RecursionSubroutines

Open in editor
# Recursive Fibonacci
SUBROUTINE fib(n)
  IF n < 2 THEN
    RETURN n
  ENDIF
  RETURN fib(n - 1) + fib(n - 2)
ENDSUBROUTINE

FOR i ← 0 TO 10
  OUTPUT fib(i)
ENDFOR
Output
0
1
1
2
3
5
8
13
21
34
55

Stack with push and pop

Implements a fixed-size stack with an array and a top pointer, including full and empty checks.

Data structuresSubroutinesArrays

Open in editor
# A stack stored in an array
CONSTANT SIZE = 3
stack ← [0, 0, 0]
top ← -1

SUBROUTINE push(item)
  IF top = SIZE - 1 THEN
    OUTPUT 'Stack full, cannot push ' + INT_TO_STRING(item)
  ELSE
    top ← top + 1
    stack[top] ← item
  ENDIF
ENDSUBROUTINE

SUBROUTINE pop()
  IF top = -1 THEN
    OUTPUT 'Stack empty'
    RETURN -1
  ENDIF
  item ← stack[top]
  top ← top - 1
  RETURN item
ENDSUBROUTINE

push(5)
push(9)
push(2)
push(7)
OUTPUT pop()
OUTPUT pop()
Output
Stack full, cannot push 7
2
9

Bubble sort

Sorts a list in place with nested loops and a swapped flag.

SortingArraysLoops

Open in editor
# Bubble sort with an early exit
items ← [29, 3, 17, 8, 42, 1]
n ← LEN(items)
swapped ← True
WHILE swapped
  swapped ← False
  FOR i ← 0 TO n - 2
    IF items[i] > items[i + 1] THEN
      temp ← items[i]
      items[i] ← items[i + 1]
      items[i + 1] ← temp
      swapped ← True
    ENDIF
  ENDFOR
  n ← n - 1
ENDWHILE
FOR item IN items
  OUTPUT item
ENDFOR
Output
1
3
8
17
29
42