You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Pseudocode is a way of writing algorithms using structured English that resembles programming code but is not written in any specific programming language. It is used to plan and communicate algorithms before they are implemented in code. Pseudocode is a core part of GCSE Computer Science — both AQA and OCR use pseudocode extensively in exam papers, and you are expected to read, write, and trace pseudocode.
Pseudocode has several advantages:
Exam Tip: In the exam, you may be asked to write pseudocode, complete partially written pseudocode, or trace through pseudocode using a trace table. Practice all three skills. The exam board's reference guide shows the specific pseudocode conventions they use — make sure you are familiar with them.
Although pseudocode is not standardised globally, GCSE exam boards use specific conventions. The following conventions are commonly used:
name ← "Alice"
age ← 16
score ← 0
The arrow ← is used for assignment (storing a value in a variable). Some exam boards also accept = for assignment.
OUTPUT "Enter your name:"
INPUT name
OUTPUT "Hello, " + name
| Operator | Meaning | Example |
|---|---|---|
| + | Addition | 5 + 3 = 8 |
| - | Subtraction | 10 - 4 = 6 |
| * | Multiplication | 6 * 7 = 42 |
| / | Division (real) | 7 / 2 = 3.5 |
| DIV | Integer division | 7 DIV 2 = 3 |
| MOD | Modulus (remainder) | 7 MOD 2 = 1 |
| ^ | Exponentiation | 2 ^ 3 = 8 |
| Operator | Meaning |
|---|---|
| = | Equal to |
| ≠ or != | Not equal to |
| < | Less than |
| > | Greater than |
| ≤ or <= | Less than or equal to |
| ≥ or >= | Greater than or equal to |
| Operator | Meaning | Example |
|---|---|---|
| AND | Both conditions must be true | age >= 13 AND age <= 19 |
| OR | At least one condition must be true | colour = "red" OR colour = "blue" |
| NOT | Reverses the truth value | NOT found |
IF score >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
END IF
IF score >= 70 THEN
grade ← "A"
ELSE IF score >= 60 THEN
grade ← "B"
ELSE IF score >= 50 THEN
grade ← "C"
ELSE
grade ← "U"
END IF
CASE day OF
"Monday": OUTPUT "Start of the week"
"Friday": OUTPUT "Almost the weekend"
"Saturday", "Sunday": OUTPUT "Weekend!"
DEFAULT: OUTPUT "Midweek"
END CASE
FOR i ← 1 TO 10
OUTPUT i
END FOR
This outputs the numbers 1 to 10. The loop variable i is automatically incremented by 1 each time.
attempts ← 0
WHILE attempts < 3
INPUT password
IF password = "correct" THEN
OUTPUT "Access granted"
attempts ← 3
ELSE
attempts ← attempts + 1
END IF
END WHILE
The condition is checked before each iteration. If it is false initially, the loop body never executes.
REPEAT
OUTPUT "Enter a positive number:"
INPUT number
UNTIL number > 0
The condition is checked after each iteration. The loop body always executes at least once.
names ← ["Alice", "Bob", "Charlie", "Diana"]
OUTPUT names[0] // Outputs "Alice" (0-indexed)
names[2] ← "Catherine" // Changes "Charlie" to "Catherine"
OUTPUT LENGTH(names) // Outputs 4
word ← "COMPUTER"
OUTPUT LENGTH(word) // Outputs 8
OUTPUT SUBSTRING(word, 0, 3) // Outputs "COM"
OUTPUT word[0] // Outputs "C"
| Operation | Description | Example |
|---|---|---|
| LENGTH(s) | Returns the number of characters | LENGTH("hello") = 5 |
| SUBSTRING(s, start, length) | Extracts part of a string | SUBSTRING("hello", 1, 3) = "ell" |
| UPPER(s) | Converts to uppercase | UPPER("hello") = "HELLO" |
| LOWER(s) | Converts to lowercase | LOWER("HELLO") = "hello" |
PROCEDURE greet(name)
OUTPUT "Hello, " + name + "!"
END PROCEDURE
greet("Alice") // Outputs "Hello, Alice!"
FUNCTION calculateArea(length, width)
area ← length * width
RETURN area
END FUNCTION
result ← calculateArea(5, 3)
OUTPUT result // Outputs 15
Exam Tip: Know the difference between a function and a procedure. A function returns a value that can be stored in a variable or used in an expression. A procedure performs an action but does not return a value.
Pseudocode is a structured way to write algorithms without using a specific programming language. It uses clear conventions for assignment, input/output, selection, iteration, arrays, strings, and subroutines. In GCSE Computer Science, you must be able to read, write, complete, and trace pseudocode. Familiarise yourself with your exam board's specific pseudocode reference guide.
Pseudocode is the language of computational thinking. It is deliberately more relaxed than real code so you can focus on the shape of the algorithm rather than the quirks of a compiler. AQA's exam papers are peppered with pseudocode — reading it fluently, writing it cleanly and tracing it carefully are three distinct skills you must master. This section goes beyond the syntactic basics and treats pseudocode as a design tool for the four computational-thinking pillars.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.