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:

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

Why Not Just Write Code? Planning with pseudocode or flowcharts first helps you focus on the logic of your solution. If you jump straight into code, you often get distracted by syntax errors and miss logical mistakes. Professional programmers almost always plan before coding — and so should you.

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:

Pseudocode
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:

Pseudocode
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:

Pseudocode
OUTPUT "Enter your age:"
INPUT age
IF age >= 18 THEN
    OUTPUT "You can vote!"
ELSE
    OUTPUT "Too young to vote."
ENDIF
Python
age = int(input("Enter your age: "))
if age >= 18:
    print("You can vote!")
else:
    print("Too young to vote.")
Key Concept: Pseudocode Pseudocode is not a real programming language — there is no single “correct” way to write it. The aim is to clearly communicate the logic of an algorithm in a way that any programmer could understand and convert into actual code. Notice how the pseudocode version maps almost 1-to-1 to the Python code.

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:

START

Terminator

Oval — marks the START or STOP of an algorithm

x = x + 1

Process

Rectangle — an action or calculation

x > 5?

Decision

Diamond — a Yes/No question

INPUT x

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:

START INPUT age age >= 18? YES OUTPUT "You can vote!" NO OUTPUT "Too young" STOP

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:

START SET count TO 5 count > 0? YES OUTPUT count count = count - 1 NO STOP

Spot the Difference: Selection vs Iteration

Both selection and iteration use a decision diamond, but there is one crucial difference:

Selection (IF Statement)

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).

Iteration (WHILE Loop)

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.

Common Mistake: Students often forget to use the correct shapes in flowcharts. Remember — rectangles are for processes, diamonds are for decisions, and parallelograms are for input/output. Using the wrong shape will lose you marks in the exam.

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.

Pseudocode — Password Validation
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.

Pseudocode — Shopping Calculator
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.

Pseudocode — Temperature Converter
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?

The scenario: A program asks the user to enter their age. If they are 17 or older, it outputs “You can learn to drive!”. Otherwise, it outputs “You are too young to drive.” The program then ends.

Your task: Draw a flowchart for this program using the correct symbols:

Reveal Model Answer — Activity 1

Flowchart steps (top to bottom):

  1. Oval: START
  2. Parallelogram: INPUT age
  3. Diamond: Is age ≥ 17?
  4. Yes → Parallelogram: OUTPUT “You can learn to drive!”
  5. No → Parallelogram: OUTPUT “You are too young to drive.”
  6. Both paths rejoin → Oval: STOP
Flowchart Diagram (text version)
        ┌───────────┐
        │   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)

The scenario: A program asks the user to enter a password. The correct password is “python123”. If the password is wrong, the program says “Incorrect, try again” and asks again. This repeats until the user enters the correct password, at which point the program outputs “Access granted!” and stops.

Your task: Draw a flowchart for this program. Think carefully about:

Reveal Model Answer — Activity 2

Flowchart steps:

  1. Oval: START
  2. Parallelogram: INPUT password
  3. Diamond: Is password = “python123”?
  4. No → Parallelogram: OUTPUT “Incorrect, try again” → arrow loops back to step 2
  5. Yes → Parallelogram: OUTPUT “Access granted!”
  6. Oval: STOP
Flowchart Diagram (text version)
          ┌───────────┐
          │   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!

Q1: What is the difference between pseudocode and actual programming code?

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.

Q2: In a flowchart, what shape represents a decision?

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.

Q3: List the common pseudocode keywords you should use in the exam.

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.

Q4: Write pseudocode for a program that finds the average of numbers in a list.

Answer:

Pseudocode
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.

Q5: Name the four flowchart symbols and state what each one represents.

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.

Q6: Describe a flowchart for a program that checks if a number is even or odd.

Answer: The flowchart would contain the following steps:

  1. Oval (Terminator): START
  2. Parallelogram (Input): INPUT number
  3. Diamond (Decision): Is number MOD 2 == 0?
  4. Yes path → Parallelogram (Output): OUTPUT “The number is even”
  5. No path → Parallelogram (Output): OUTPUT “The number is odd”
  6. 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.

Q7: What is wrong with using Python syntax in a pseudocode answer?

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.

Q8: How can you tell the difference between selection and iteration in a flowchart?

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:

Pseudocode
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

LineInstruction
1INPUT x
2SET y TO 0
3WHILE x > 0:
4    SET y TO y + x
5    SET x TO x - 2
6ENDWHILE
7OUTPUT y

Mark scheme: Trace table (1 mark per correct row of working, 1 mark for correct output):

xyx > 0?
70Yes
57Yes
312Yes
115Yes
-116No

Output: 16

Key Vocabulary

Make sure you understand and can define all of these terms.

TermDefinition
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:

Top Exam Tip: If you are running out of time and cannot finish a trace table, at least write down your final answer with a brief explanation. You may still get the mark for the correct answer, and partial working often picks up method marks. Never leave an algorithm question blank.

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:

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

Interactive Games

Further Reading & External Resources