Skip to content
World first

ZAK's Pseudocode Playground

Write pseudocode exactly as you would in Paper 2 — DECLARE, ←, IF/ENDIF, FOR/NEXT, PROCEDURE, arrays, records, files — and run it. Supports the 2210 / 0478 and 9618 pseudocode guides. Your code is saved in your browser. Stuck? Press Examples for 160 runnable programs, filterable by level and topic.

Loading playground…

Example library

160 programs · 87 for O Level 2210 · 113 for AS Level 9618 · 61 for A2 Level 9618. Search and filter them with the Examples button, or open one directly from its Learn topic page.

  • Basics & data types 13

    Variables, constants, INPUT/OUTPUT, arithmetic, DIV/MOD, conversions

  • Selection 8

    IF/ELSE, nested IF, CASE with lists and ranges, Boolean conditions

  • Iteration 12

    FOR, WHILE, REPEAT, nested loops, totalling, counting, max/min

  • String handling 13

    LENGTH, SUBSTRING/MID, UCASE/LCASE, ASC/CHR, reversing, palindromes, ciphers

  • Arrays 9

    1D and 2D arrays, parallel arrays, whole-array copy, frequency counts

  • Procedures & functions 9

    Parameters, RETURN, BYREF vs BYVAL, scope, stepwise refinement

  • Validation, testing & exceptions 12

    Range, length, type, format and check-digit checks; verification; test data; trace tables; TRY … EXCEPT

  • Searching 7

    Linear search, binary search (iterative and recursive), comparing efficiency

  • Sorting 7

    Bubble sort (with and without a flag), insertion sort, sorting strings and parallel arrays

  • File handling 9

    Text files (READ/WRITE/APPEND, EOF), delimited records, random-access files

  • Records & user-defined types 6

    TYPE…ENDTYPE records, arrays of records, enumerated, pointer and set types, DATE

  • Stacks, queues, lists & trees 14

    Stack, linear and circular queue, linked list, binary search tree, hash table, dictionary

  • Recursion 10

    Base and general cases, winding/unwinding, factorial, Fibonacci, GCD, Hanoi

  • Object-oriented programming 9

    Classes, constructors, encapsulation, inheritance, polymorphism, containment

  • Theory in code 16

    Number bases, two's complement, parity, logic gates, adders, FDE cycle, compression, floating point, RPN, graphs

  • Exam-style tasks 6

    Complete scenario programs in the style of 2210 Section B, 9618 Paper 2 and Paper 4

What's supported?
  • Declarations: DECLARE x : INTEGER / REAL / STRING / CHAR / BOOLEAN, CONSTANT, ARRAY[1:10] and ARRAY[1:3, 1:4], TYPE … ENDTYPE records
  • Assignment: ← or <- (using = for assignment gives a helpful error, like the examiner would)
  • Selection: IF … THEN … ELSE … ENDIF, CASE OF … OTHERWISE … ENDCASE (with ranges like 5 TO 9)
  • Loops: FOR … TO … STEP … NEXT, WHILE … DO … ENDWHILE, REPEAT … UNTIL
  • Subroutines: PROCEDURE / FUNCTION … RETURNS, CALL, RETURN, BYVAL / BYREF, recursion
  • Built-ins: LENGTH, UCASE, LCASE, SUBSTRING, LEFT, RIGHT, MID, ROUND, RANDOM, INT, DIV, MOD, NUM_TO_STR, STR_TO_NUM, CHR, ASC
  • Files: OPENFILE FOR READ/WRITE/APPEND, READFILE, WRITEFILE, EOF, CLOSEFILE (in-memory)
  • OOP (9618): CLASS … ENDCLASS, INHERITS, PRIVATE/PUBLIC attributes and methods, PROCEDURE NEW constructors, SUPER.NEW, NEW ClassName(…), obj.Method() — private access from outside is rejected like an examiner would.
  • User-defined types (§4): TYPE Season = (…) enumerated with +1/comparisons, TYPE P = ^INTEGER pointers with ^Var and Ptr^, TYPE S = SET OF … with DEFINE and IN, DATE literals dd/mm/yyyy.
  • Exception handling (A2 §20.3): TRY … EXCEPT … ENDTRY with ERRORMESSAGE() — catches runtime errors (division by zero, STR_TO_NUM on text, index out of range, file not open) so the program continues.
  • Random files (§9.2): OPENFILE … FOR RANDOM, SEEK, GETRECORD, PUTRECORD.
  • Guide rules enforced: CONSTANT must be a literal (§2.5); no BYREF in functions (§8.3); 9618 WHILE without DO and 2210 / 0478 WHILE … DO both accepted.
Enroll nowOnline classes