Representing Algorithms
Once you have used computational thinking to plan a solution, you need a way to write it down clearly before turning it into code. There are two main ways to represent an algorithm:
- Pseudocode — A structured, text-based way of describing the steps, using English words that resemble programming keywords
- Flowcharts — A visual diagram that shows the steps and decisions using standard shapes connected by arrows
Both methods let you plan your logic without worrying about the syntax rules of any particular programming language. They are essential skills for GCSE Computer Science — you will be asked to read, write, and trace through both pseudocode and flowcharts in the exam.
Why Use Pseudocode & Flowcharts?
Focus on Logic
Plan your solution without getting distracted by syntax errors or language-specific rules
Anyone Can Read It
Pseudocode is language-independent — any programmer can understand it, regardless of what language they use
Easy to Convert
Well-written pseudocode translates directly into any programming language with minimal effort
Pseudocode in Action
Pseudocode is a way of writing an algorithm using structured English that looks a bit like programming code, but is not written in any specific language. It lets you plan your logic without worrying about syntax rules.
Pseudocode Keywords
These are the standard keywords you should use when writing pseudocode in the exam:
| Keyword | What It Does | Example |
|---|---|---|
INPUT |
Gets data from the user | INPUT name |
OUTPUT |
Displays data to the user | OUTPUT "Hello" |
SET...TO |
Assigns a value to a variable | SET total TO 0 |
IF...THEN...ELSE...ENDIF |
Makes a decision (selection) | IF age >= 18 THEN |
FOR...ENDFOR |
Repeats a set number of times | FOR i = 1 TO 10 |
WHILE...ENDWHILE |
Repeats while a condition is true | WHILE count < 5 |
REPEAT...UNTIL |
Repeats until a condition is true | REPEAT...UNTIL answer = "yes" |
A Simple Example
Here is a simple algorithm to check if a student has passed an exam:
INPUT score
IF score >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
And a slightly more complex example — finding the largest number in a list:
INPUT numbers (a list of values)
SET largest TO numbers[0]
FOR EACH number IN numbers
IF number > largest THEN
SET largest TO number
ENDIF
ENDFOR
OUTPUT largest
Pseudocode vs Python: Side by Side
Pseudocode is designed to be easy to convert into any programming language. Compare this voting-age checker written in both pseudocode and Python:
OUTPUT "Enter your age:"
INPUT age
IF age >= 18 THEN
OUTPUT "You can vote!"
ELSE
OUTPUT "Too young to vote."
ENDIF
age = int(input("Enter your age: "))
if age >= 18:
print("You can vote!")
else:
print("Too young to vote.")
Flowcharts: Visual Algorithms
A flowchart is a visual diagram that shows the steps of an algorithm using standard symbols connected by arrows. They make it easy to see the flow of logic at a glance — especially for algorithms that involve decisions and loops.
Flowchart Symbols
You must know these four key flowchart symbols for the exam:
Terminator
Oval — marks the START or STOP of an algorithm
Process
Rectangle — an action or calculation
Decision
Diamond — a Yes/No question
Input / Output
Parallelogram — data in or results out
Arrows connect the symbols and show which step comes next. Decision diamonds always have two paths coming out: one for “Yes” and one for “No.”
Flowchart Example: Selection (IF Statement)
This flowchart shows the voting-age checker — an example of selection, where the program takes a different path depending on a condition:
Flowchart Example: Iteration (WHILE Loop)
This flowchart shows a countdown from 5 to 1 — an example of iteration, where steps are repeated while a condition is true:
Spot the Difference: Selection vs Iteration
Both selection and iteration use a decision diamond, but there is one crucial difference:
The flowchart branches into two paths — one path for YES, another for NO. Both paths continue forward and eventually meet up again. The code inside is executed once (or not at all).
One path from the decision loops back to a previous step, creating a cycle. The code inside can be executed many times until the condition changes. Look for the arrow going backwards.
Pseudocode in Detail: Worked Examples
Here are three practical algorithms written in pseudocode. Practise reading through each one and tracing the logic step by step.
Example 1: Password Validation
This algorithm checks whether a password meets three rules: it must be at least 8 characters long, contain at least one uppercase letter, and contain at least one digit.
INPUT password
SET hasUpper TO FALSE
SET hasDigit TO FALSE
IF LENGTH(password) < 8 THEN
OUTPUT "Password must be at least 8 characters long"
STOP
ENDIF
FOR EACH character IN password
IF character is an uppercase letter THEN
SET hasUpper TO TRUE
ENDIF
IF character is a digit THEN
SET hasDigit TO TRUE
ENDIF
ENDFOR
IF hasUpper == TRUE AND hasDigit == TRUE THEN
OUTPUT "Password accepted"
ELSE
IF hasUpper == FALSE THEN
OUTPUT "Password must contain at least one uppercase letter"
ENDIF
IF hasDigit == FALSE THEN
OUTPUT "Password must contain at least one digit"
ENDIF
ENDIF
Example 2: Shopping Total Calculator with Discount
This algorithm calculates the total cost of items in a shopping basket and applies a 10% discount if the total exceeds £50.
SET total TO 0
SET itemCount TO 0
REPEAT
OUTPUT "Enter item price (or 0 to finish):"
INPUT price
IF price != 0 THEN
SET total TO total + price
SET itemCount TO itemCount + 1
ENDIF
UNTIL price == 0
OUTPUT "Items purchased: " + itemCount
OUTPUT "Subtotal: £" + total
IF total > 50 THEN
SET discount TO total * 0.10
SET total TO total - discount
OUTPUT "10% discount applied: -£" + discount
ENDIF
OUTPUT "Total to pay: £" + total
Example 3: Temperature Converter
This algorithm lets the user choose a conversion direction and then converts between Celsius and Fahrenheit.
OUTPUT "Temperature Converter"
OUTPUT "1. Celsius to Fahrenheit"
OUTPUT "2. Fahrenheit to Celsius"
OUTPUT "Enter your choice (1 or 2):"
INPUT choice
IF choice == 1 THEN
OUTPUT "Enter temperature in Celsius:"
INPUT celsius
SET fahrenheit TO (celsius * 9 / 5) + 32
OUTPUT celsius + "°C = " + fahrenheit + "°F"
ELSEIF choice == 2 THEN
OUTPUT "Enter temperature in Fahrenheit:"
INPUT fahrenheit
SET celsius TO (fahrenheit - 32) * 5 / 9
OUTPUT fahrenheit + "°F = " + celsius + "°C"
ELSE
OUTPUT "Invalid choice. Please enter 1 or 2."
ENDIF
Flowchart Symbols: Quick Reference Table
| Shape | Name | What It Means | Example |
|---|---|---|---|
| Oval (rounded rectangle) | Terminator | Start or End of the algorithm | START / STOP |
| Rectangle | Process | An action or calculation | total = price * quantity |
| Diamond | Decision | A Yes/No question (selection) | Is score >= 50? |
| Parallelogram | Input/Output | Data going in or results coming out | INPUT name / OUTPUT result |
Flowchart Activities
Put your flowchart skills into practice! Use the free online tool below to draw your flowcharts, then check your answer with the accordion.
Open Think2Code Flowchart Tool →
Tip: Use the Think2Code tool to drag and drop flowchart symbols onto the canvas. Connect them with arrows and remember to label your Yes/No paths on decision diamonds!
Activity 1: Can You Drive?
Your task: Draw a flowchart for this program using the correct symbols:
- Oval for Start and Stop
- Parallelogram for Input (age) and Output (message)
- Diamond for the decision (Is age ≥ 17?)
- Arrows with Yes/No labels on the decision paths
Flowchart steps (top to bottom):
- Oval: START
- Parallelogram: INPUT age
- Diamond: Is age ≥ 17?
- Yes → Parallelogram: OUTPUT “You can learn to drive!”
- No → Parallelogram: OUTPUT “You are too young to drive.”
- Both paths rejoin → Oval: STOP
┌───────────┐
│ START │ (oval)
└─────┬─────┘
▼
╱ ╲
╱ INPUT age ╲ (parallelogram)
╲ ╱
╲ ╱
│
▼
╱ ╲
╱ Is age ╲
╱ >= 17? ╲ (diamond)
╲ ╱
╲ ╱
Yes ╲ ╱ No
│ │
▼ ▼
╱─────────╲ ╱──────────────╲
╱ OUTPUT ╲╱ OUTPUT ╲
╲ "You can ╱╲ "Too young ╱
╲ drive!" ╱ ╲ to drive." ╱
│ │
└─────┬─────┘
▼
┌───────────┐
│ STOP │ (oval)
└───────────┘
Key points: This is a selection (IF/ELSE) flowchart — notice both paths go forward and rejoin. There are no backward arrows, so there is no loop.
Activity 2: Password Checker (with a Loop)
Your task: Draw a flowchart for this program. Think carefully about:
- Where does the loop go back to? (Which step repeats?)
- Which symbol represents the decision?
- Where does the backward arrow go? (This is what makes it iteration, not selection!)
Flowchart steps:
- Oval: START
- Parallelogram: INPUT password
- Diamond: Is password = “python123”?
- No → Parallelogram: OUTPUT “Incorrect, try again” → arrow loops back to step 2
- Yes → Parallelogram: OUTPUT “Access granted!”
- Oval: STOP
┌───────────┐
│ START │ (oval)
└─────┬─────┘
▼
┌──╱ ╲
│ ╱INPUT password╲ (parallelogram)
│ ╲ ╱
│ ╲ ╱
│ │
│ ▼
│ ╱ ╲
│ ╱password ╲
│ ╱= python ╲ (diamond)
│ ╲ 123? ╱
│ ╲ ╱
│ No ╲ ╱ Yes
│ │ │
│ ▼ ▼
│ ╱─────────╲ ╱──────────╲
│╱ OUTPUT ╲╱ OUTPUT ╲
│╲"Incorrect,╱╲ "Access ╱
│ ╲try again"╱ ╲granted!" ╱
│ │ │
└────┘ ▼
┌───────────┐
│ STOP │ (oval)
└───────────┘
▲
The backward arrow makes
this ITERATION (a loop)!
Key points: This is iteration (a WHILE loop) — notice the backward arrow from the “Incorrect” output back to the INPUT step. This is how you can tell the difference between selection and iteration in a flowchart: look for the backward arrow.
Test Yourself
Click on each question to reveal the answer. Try to answer in your head first!
Answer: Pseudocode is written in structured English and is not tied to any specific programming language. It cannot be executed by a computer. Its purpose is to plan and communicate the logic of an algorithm in a way that any programmer can understand, regardless of which language they use.
Answer: A diamond shape represents a decision (a Yes/No question). It always has two paths coming out of it — one for Yes (true) and one for No (false). Other shapes: oval = start/end, rectangle = process, parallelogram = input/output.
Answer: The standard keywords are: INPUT, OUTPUT, IF...THEN...ELSE...ENDIF, FOR...ENDFOR, WHILE...ENDWHILE, REPEAT...UNTIL, SET...TO, and STOP. Using these consistently shows the examiner that you understand pseudocode conventions.
Answer:
INPUT numbers (a list of values)
SET total TO 0
SET count TO LENGTH(numbers)
FOR EACH number IN numbers
SET total TO total + number
ENDFOR
SET average TO total / count
OUTPUT "The average is: " + average
The key steps are: (1) add up all the values using a loop, (2) divide the total by the number of items. Remember to use a variable to accumulate the running total.
Answer: (1) Oval (Terminator) — marks the START or STOP of an algorithm. (2) Rectangle (Process) — represents an action or calculation. (3) Diamond (Decision) — represents a Yes/No question that creates two paths. (4) Parallelogram (Input/Output) — represents data going in or results coming out.
Answer: The flowchart would contain the following steps:
- Oval (Terminator): START
- Parallelogram (Input): INPUT number
- Diamond (Decision): Is number MOD 2 == 0?
- Yes path → Parallelogram (Output): OUTPUT “The number is even”
- No path → Parallelogram (Output): OUTPUT “The number is odd”
- Both paths lead to → Oval (Terminator): STOP
Remember: the decision diamond must have two labelled exits (Yes/No), and input/output boxes must be parallelograms, not rectangles.
Answer: Pseudocode should be language-independent. If the question asks for pseudocode and you write print() instead of OUTPUT, or input() instead of INPUT, the examiner may not award full marks. Pseudocode should use the standard keywords (IF, THEN, ELSE, FOR, WHILE, etc.) rather than any specific programming language’s syntax.
Answer: Both use a diamond (decision) shape, but the key difference is in the arrows:
- Selection (IF): Both paths from the diamond go forward — they branch and then rejoin. No arrow goes backwards.
- Iteration (WHILE/REPEAT): One path from the diamond creates a loop — an arrow goes back to a previous step, creating a cycle that repeats.
Look for the backward arrow — if there is one, it’s iteration. If both paths only go forward, it’s selection.
Past Paper Questions
Try these exam-style questions, then click to reveal the mark scheme answer.
Describe what is meant by pseudocode. 2 marks
Mark scheme:
- Pseudocode is a way of writing/describing an algorithm (1)
- using structured English / not in a specific programming language / cannot be executed by a computer (1)
Draw the four standard flowchart symbols and state what each one represents. 4 marks
Mark scheme: One mark for each correct symbol with its name/description:
- Oval/rounded rectangle — Terminator (Start/Stop) (1)
- Rectangle — Process (action/calculation) (1)
- Diamond — Decision (Yes/No question) (1)
- Parallelogram — Input/Output (1)
Write pseudocode for a program that asks the user to enter numbers until they enter −1. The program should then output the total of all the numbers entered (not including −1). 5 marks
Mark scheme:
SET total TO 0 (1)
INPUT number (1)
WHILE number != -1 (1)
SET total TO total + number (1)
INPUT number
ENDWHILE
OUTPUT total (1)
Accept equivalent solutions using REPEAT...UNTIL. Key marks: initialisation of total, input before loop, correct loop condition, accumulation, output after loop.
Explain the difference between how selection and iteration are shown in a flowchart. 3 marks
Mark scheme:
- Both use a diamond/decision symbol (1)
- In selection, the two paths go forward and rejoin / no path loops back (1)
- In iteration, one path loops back to a previous step / creates a cycle (1)
A program uses the following pseudocode. Trace through the algorithm and state the output when the input is 7.
4 marks
Line Instruction
1 INPUT x
2 SET y TO 0
3 WHILE x > 0:
4 SET y TO y + x
5 SET x TO x - 2
6 ENDWHILE
7 OUTPUT y
INPUT xSET y TO 0WHILE x > 0: SET y TO y + x SET x TO x - 2ENDWHILEOUTPUT yMark scheme: Trace table (1 mark per correct row of working, 1 mark for correct output):
| x | y | x > 0? |
|---|---|---|
| 7 | 0 | Yes |
| 5 | 7 | Yes |
| 3 | 12 | Yes |
| 1 | 15 | Yes |
| -1 | 16 | No |
Output: 16
Key Vocabulary
Make sure you understand and can define all of these terms.
| Term | Definition |
|---|---|
| Algorithm | A step-by-step set of instructions for solving a problem or completing a task. It must be precise, ordered, and finite. |
| Pseudocode | A way of writing an algorithm in structured English that resembles code but is not tied to any programming language. |
| Flowchart | A visual diagram that represents an algorithm using standard shapes (ovals, rectangles, diamonds, parallelograms) connected by arrows. |
| Terminator | An oval shape in a flowchart that marks the START or STOP of an algorithm. |
| Process | A rectangle shape in a flowchart that represents an action or calculation being performed. |
| Decision | A diamond shape in a flowchart that represents a Yes/No question, creating two possible paths. |
| Input/Output | A parallelogram shape in a flowchart that represents data being entered or results being displayed. |
| Selection | A programming construct where the program chooses between two or more paths based on a condition (IF...THEN...ELSE). |
| Iteration | A programming construct where steps are repeated (looped) using FOR, WHILE, or REPEAT...UNTIL. |
| Trace Table | A table used to track the values of variables as you step through an algorithm, used to test and debug logic. |
| Sequence | A programming construct where instructions are carried out one after another, in order. |
| Variable | A named storage location that holds a value which can change during program execution. |
| Constant | A named storage location that holds a value which is set once and cannot change. Written in UPPERCASE (e.g. VAT_RATE). |
| DIV | Integer division — divides and gives the whole number only, ignoring the remainder (e.g. 7 DIV 2 = 3). |
| MOD | Modulus — gives the remainder after division (e.g. 7 MOD 2 = 1). Used to check even/odd numbers. |
Exam Tips: Pseudocode & Flowchart Questions
1. Trace Tables: Show Your Working
When asked to trace through an algorithm, always use a trace table. Write a column for each variable and a row for each step. This makes your working clear to the examiner, and even if your final answer is wrong, you can still pick up method marks for correct intermediate steps.
2. Use Correct Pseudocode Keywords
If the question asks you to write pseudocode, use the standard keywords: IF...THEN...ELSE...ENDIF, FOR...ENDFOR, WHILE...ENDWHILE, REPEAT...UNTIL, INPUT, OUTPUT, SET...TO. Avoid writing in Python or any specific language unless the question asks for it.
3. Flowchart Questions: Use the Right Shapes
If you are asked to draw a flowchart, use the correct shapes. Using a rectangle where a diamond should be — or forgetting parallelograms for input/output — will cost you marks, even if the logic is correct.
4. Check Your Logic Flows
When drawing flowcharts, make sure all paths eventually lead to the STOP terminator. Decision diamonds must have exactly two exits labelled “Yes” and “No.” Loops should have a clear path back to an earlier step.
5. What Exam Questions Look Like
In exams, you might be asked to:
- Complete missing parts of flowcharts or pseudocode
- Identify whether a flowchart shows selection or iteration
- Convert between flowcharts and pseudocode
- Trace through a flowchart or pseudocode with given input values
- Identify whether something should be a variable or constant
- Fix incorrect variable names or pseudocode
Think About It
Pseudocode and flowcharts are not just exam skills — they are tools that professional developers use every day. Before writing a single line of code, programmers often sketch out the logic on paper or a whiteboard.
Think about when each representation is most useful:
- Pseudocode is great for linear processes and when you need to show detailed logic, variable names, and calculations
- Flowcharts are great for visualising decision-making and loops — you can see at a glance where the program branches
Next time you have a programming challenge, try writing the pseudocode or drawing a flowchart before you touch the keyboard. You will be surprised how much easier the coding becomes when the logic is already clear in your head.
Video Resources
These videos from Craig 'n' Dave cover the key concepts in more detail:
Interactive Activities
- Trace Table Challenge — Step through pseudocode execution and track variable values in a trace table
- Trace Table Challenge 2 — More advanced tracing with output generation and execution flow
- Code Sequencing — Arrange code blocks into the correct sequence across 3 challenges
Interactive Games
- Program Builder — 14 drag-and-drop challenges turning pseudocode into working code
- Programming Mindmap — Interactive visual overview of programming concepts
Further Reading & External Resources
- BBC Bitesize — Edexcel GCSE Computer Science — Comprehensive coverage of pseudocode and flowcharts
- Isaac Computer Science — Programming Concepts — Interactive explanations of pseudocode conventions
- W3Schools — Data Structures and Algorithms — Beginner-friendly tutorials with try-it-yourself examples