KS3 · Computer Science

Flowcharts for algorithms

A flowchart adds 5 to a number while it's under 20. Start it at 8. Does it output 20? Most people think so. Follow the arrows and find out.

Computer Science · Flowcharts

Saving up: follow the flow

Money starts at 8, and 5 gets added while it's under 20. Guess the output first. Then step through and watch which symbol lights up.

Predict before you step: what does this flowchart output?

YesNoStartINPUT moneymoney < 20?money = money + 5OUTPUT moneyEnd

Output

 

Step 1: Off we go. The arrows decide what happens next, not where the boxes sit.

1 / 11

Press Next one step at a time. Before each step, say out loud where the arrow goes.

Step 1 of 11: Off we go. The arrows decide what happens next, not where the boxes sit..

Watch out: The flow only leaves the loop when it reaches the diamond and the answer is No. It doesn't stop the moment money 'gets close' to 20.

Computer Science · Flowcharts

Which shape does it go in?

Pick a step, then pick the symbol that should hold it.

Still to sort

Terminator (oval or rounded rectangle) (0)

Marks the start or the end of the algorithm.

Process (rectangle) (0)

An instruction or a calculation.

Where the line is: If data is coming in from outside or a result is going out, it's input/output, not a process.

Input/output (parallelogram) (0)

Data coming in, or results going out.

Decision (diamond) (0)

A yes/no question with two exits.

Where the line is: The algorithm answers this question itself, Yes or No, to choose a path. Asking the user to type something is input, not a decision.

8 of 8 still to sort.

The shape tells you what kind of step it is before you've even read the words. Sort each step into its symbol.

Watch out: A step that starts with 'Ask' isn't automatically a decision. If the user types something in, it's input.

Computer Science · Flowcharts

Your turn: words into a flowchart

Turn this into a flowchart: "Keep asking for a password until it is correct, then display Welcome."

  1. Draw a Start terminator, then an arrow to INPUT password in a parallelogram.
  2. missing step
Which line is step 2?

Exam line: Before you call it finished, check: one Start, at least one End, every step in its proper symbol, both exits of every decision labelled, and an arrow joining every step.

Computer Science · Loops

So what actually stops a loop?

Start → n = 1 → decision "n > 5?". No: n = n + 1, then an arrow back to the decision. Yes: OUTPUT n → End.

Which is closest to what you think stops this loop?
How sure are you?

Computer Science · Tracing

Find where Sam's trace goes wrong

Ticket price flowchart: Start → INPUT age → decision "age < 12?". Yes: price = 5. No: price = 8. Then OUTPUT price → End. Sam traces it with age = 14.

Sam's trace — which line goes wrong?

Exam line: When a trace gives a surprising answer, go back to the first decision and check it with the actual value.

Which flowchart is better?

Flowchart 1: one decision. "A > B?" Yes: OUTPUT A. No: OUTPUT B.vsFlowchart 2: two decisions. "A > B?" Yes: OUTPUT A. No: "B > A?" Yes: OUTPUT B. No: End.

Both are meant to output the larger of two numbers, A and B. If they're equal, outputting either one is fine.

Focus

Test: A = 6, B = 6

Flowchart 1: one decision. "A > B?" Yes: OUTPUT A. No: OUTPUT B.

A > B? No. OUTPUT B, so it outputs 6. Correct.

Flowchart 2: two decisions. "A > B?" Yes: OUTPUT A. No: "B > A?" Yes: OUTPUT B. No: End.

A > B? No. B > A? No. End. It outputs nothing. Wrong.

The insight

Lead with the input that breaks one of them. Equal numbers get a No from both questions in Flowchart 2, so the flow reaches End with nothing output.

Test: A = 9, B = 2

Flowchart 1: one decision. "A > B?" Yes: OUTPUT A. No: OUTPUT B.

A > B? Yes. Outputs 9.

Flowchart 2: two decisions. "A > B?" Yes: OUTPUT A. No: "B > A?" Yes: OUTPUT B. No: End.

A > B? Yes. Outputs 9.

Test: A = 3, B = 7

Flowchart 1: one decision. "A > B?" Yes: OUTPUT A. No: OUTPUT B.

1 decision, then OUTPUT B. Outputs 7.

Flowchart 2: two decisions. "A > B?" Yes: OUTPUT A. No: "B > A?" Yes: OUTPUT B. No: End.

2 decisions, then OUTPUT B. Outputs 7.

Works for every pair of numbers?

Flowchart 1: one decision. "A > B?" Yes: OUTPUT A. No: OUTPUT B.

Yes. Reason it out: A > B is either Yes (A is larger) or No (B is larger or equal), and each exit outputs the right number.

Flowchart 2: two decisions. "A > B?" Yes: OUTPUT A. No: "B > A?" Yes: OUTPUT B. No: End.

No. It fails whenever A and B are equal.

Verdict

Flowchart 1: one decision. "A > B?" Yes: OUTPUT A. No: OUTPUT B.

Better: works for every pair, and fewer steps.

Flowchart 2: two decisions. "A > B?" Yes: OUTPUT A. No: "B > A?" Yes: OUTPUT B. No: End.

Worse: more steps, and wrong for some inputs.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

A flowchart is an algorithm you can follow with your finger. The arrows set the order, a diamond picks the path, and an arrow pointing back makes steps repeat until a decision lets the flow out.

What you need to know

  • An algorithm is a precise, ordered set of steps for solving a problem. You can plan it before it's programmed, as a flowchart or written steps.
  • A flowchart draws an algorithm as standard shapes joined by arrows. The arrows set the order, not where the boxes sit.
  • Start and End go in a terminator: an oval or a rounded rectangle.
  • A rectangle is a process: an instruction or calculation. A parallelogram is input or output: data coming in, results going out.
  • Have a goYour mate Kai puts OUTPUT total in a rectangle. "It's an instruction, so it's a process. Obviously." Is Kai right? Which shape should it be?

    Not quite: it belongs in a parallelogram.

    Showing a result is output, and output goes in a parallelogram. A rectangle is only for processes such as instructions and calculations.

  • Selection: a diamond holds a yes/no question with two exits, and the answer picks the one path the flow takes.
  • Have a goA diamond asks "Is it raining?" and the answer is No. How many of the diamond's two exits does the flow go down?

    Just one: the No exit.

    A decision picks one path. The steps on the Yes path are skipped this time; the flow never goes down both.

  • Sequence: on a path with no decision and no arrow back, each step is carried out once, in arrow order.
  • Iteration: an arrow back to an earlier step repeats a group of steps, and a decision controls when the repeating stops.
  • Have a gon starts at 0. A diamond asks "n < 3?". Yes: n = n + 1, then an arrow back to the diamond. No: End. How many times does n = n + 1 run?

    3 times (n becomes 1, then 2, then 3).

    The question is asked 4 times, at 0, 1, 2 and 3. At 3, 3 < 3 is false, so the flow leaves. Counting the asks instead of the adds gives 4.

  • Drawing one? One Start, at least one End, each step in its proper symbol, both decision exits labelled, and arrows joining every step.
  • Trace it: follow the arrows from Start with a real input, noting values as they change. That finds the output, and the errors.
  • Comparing two flowcharts for one job? First check each works for every input you need, boundary cases included. Then compare steps.

The big picture

A flowchart draws an algorithm as standard shapes joined by arrows, and the arrows set the order. Terminators hold Start and End, rectangles hold processes, parallelograms hold input and output, and diamonds hold decisions with two exits. Steps run in sequence, branch at a decision (selection), or repeat when an arrow leads back, with a decision controlling when the repeating stops (iteration). Trace with real inputs to find the output and catch errors, and compare two flowcharts by checking they work for the inputs that matter before counting steps.

Key points

1Algorithm: a precise, ordered set of steps. Flowchart: that algorithm drawn as shapes joined by arrows.
2The arrows set the order, not the position of the boxes on the page.
3Oval or rounded rectangle = Start/End. Rectangle = process. Parallelogram = input/output. Diamond = decision.
4A decision has two labelled exits, such as Yes/No or True/False, and the answer picks which one the flow takes.
5A loop is an arrow back to an earlier step, and a decision controls when it stops. An arrow back with no way out repeats for ever.
6Trace with real inputs to find the output and to catch errors.
7When comparing flowcharts, check they work for the inputs that matter, including boundary cases, before comparing steps.

Worked example

Problem

Trace this flowchart with an input of 4 and write down everything it outputs. Start → INPUT n → count = 1 → decision "count ≤ 3?". Yes: OUTPUT n × count, then count = count + 1, then an arrow back up to the decision. No: End.

⚠ Watch out

Thinking a loop stops by itself, or stops when the value gets close to the number in the decision. It stops only when the flow reaches the decision and the answer sends it out. An arrow back with no decision and no other exit repeats for ever.

🧠

Memory hook

Ovals open and close, rectangles do, parallelograms pass data in and out, and diamonds decide. A loop goes round until its diamond lets it out.

✓

Check yourself

Sketch the four symbols and say what each one holds. In a loop, what decides when the repeating stops? How would you decide which of two flowcharts for the same job is better?

Flashcards

(14)
What is an algorithm?
A precise, ordered set of steps (instructions) for solving a problem or completing a task.
What is a flowchart?
A diagram that represents an algorithm using standard shapes joined by arrows (flow lines).
In a flowchart, what do the arrows show?
The order in which the steps are carried out, whatever their position on the page.
Which symbol marks Start and End, and what shape is it?
A terminator: an oval or a rounded rectangle.
What goes in a rectangle (process box)?
An instruction or a calculation, such as total = total + 2.
What does a parallelogram show?
Input or output: data coming in, or results going out.
What does a diamond hold, and how many exits does it have?
A decision: a yes/no (true/false) question with two exits, each labelled with its answer.
What is sequence in a flowchart?
Steps following one after another along the arrows, each carried out once, with no branch and no arrow back.
What is selection in a flowchart?
A decision asks a yes/no question, and the algorithm follows a different path depending on the answer.
How does iteration (repetition) appear in a flowchart?
An arrow leads back to an earlier step, so a group of steps repeats.
In a flowchart loop, what controls when the repeating stops?
A decision. Each time the flow reaches it, its answer either sends the flow round again or out of the loop.
What happens if an arrow loops back with no decision and no other exit?
The steps repeat for ever: nothing ever sends the flow out.
What does it mean to trace a flowchart?
Follow it step by step from Start to End with given inputs to work out its output, and check it does what it should.
Why can't one successful test prove a flowchart is correct?
Other inputs, such as boundary cases, may still break it. Reason about every path and test the boundary inputs too.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More KS3 Computer Science topics

See the full KS3 Computer Science curriculum →

How this lesson was checked. This KS3 Computer Sciencelesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 27 October 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.

Helpful guides for parents and students