Cambridge pseudocode online compiler
Write pseudocode the way Cambridge A Level 9618, IGCSE 0478 and O Level 2210 papers do, and run it. See the output, find the line with the mistake, and share your program with a link.
Runs in your browser. Ctrl/⌘ + Enter to run.
What it runs
- Variables and types
- DECLARE (one or several names), CONSTANT, INTEGER, REAL, STRING, CHAR, BOOLEAN, 1D and 2D ARRAY, TYPE … ENDTYPE records
- Selection
- IF … THEN … ELSE … ENDIF, CASE OF … OTHERWISE … ENDCASE
- Iteration
- FOR … TO … STEP … NEXT, WHILE … DO … ENDWHILE, REPEAT … UNTIL
- Subroutines
- PROCEDURE and FUNCTION with parameters, BYVAL and BYREF, RETURNS, RETURN, CALL
- Input and output
- INPUT (from the inputs box, one line each), OUTPUT
- Files
- OPENFILE … FOR READ / WRITE / APPEND, READFILE, WRITEFILE, CLOSEFILE, EOF()
- Operators
- <- assignment, + - * / ^, DIV and MOD, = <> < > <= >=, AND OR NOT, & to join strings
- Built-in functions
- LENGTH, SUBSTRING, MID, LEFT, RIGHT, UCASE, LCASE, TO_UPPER, TO_LOWER, ASC, CHR, INT, ROUND, RANDOM, RAND, NUM_TO_STR, STR_TO_NUM, IS_NUM
Keywords can be typed in any case, but exam answers should use capitals. In A Level mode the style notes flag habits examiners dislike, such as = for assignment or Python’s print().
Questions
Is this the official Cambridge pseudocode compiler?
No. Cambridge pseudocode isn’t a real programming language and Cambridge doesn’t publish a compiler for it. This is our own interpreter, written to follow the pseudocode style used in the 9618 and 0478 syllabuses. It’s the same engine that runs pseudocode answers in Redpen’s practice questions.
What’s the difference between the 9618 and 0478 modes?
In A Level 9618 mode every variable must be declared with DECLARE before it’s used, as the 9618 guide expects. In IGCSE 0478 / O Level 2210 mode you can assign to a variable without declaring it first, because 0478 answers often do and the mark schemes don’t penalise it. Both modes accept 0478 forms like DIV(x, y), MOD(x, y), ROUND(x, places) and CONSTANT Rate <- 6.5.
How does INPUT work?
Type the values your program will read into the inputs box, one per line. Each INPUT statement takes the next line. A number typed into an INTEGER or REAL variable becomes a number, and TRUE or FALSE into a BOOLEAN becomes a boolean.
Will the examiner mark my answer the way this runs it?
Examiners mark the logic, not whether it runs. A program that runs here can still miss marking points, and small slips an examiner would forgive can stop it running. To see how an answer would actually be marked, try a free Redpen audit: six exam-style questions, with pseudocode run against test cases and written answers marked point by point.
Is my code saved or sent anywhere?
No. It runs in your browser and nothing is sent to a server. The Share button puts your program into the link itself, so whoever opens the link sees the same code.