- Home
- Lessons
- KS3 Computing
- Algorithms and flowcharts
Algorithms and flowcharts
🎬 The doodle video for this lesson is coming soon. Subscribe on YouTube to see it first.
An algorithm is a precise set of steps. Flowcharts show an algorithm as a diagram, so you can follow it before writing any code.
Sequence, selection and iteration
Every algorithm is built from three building blocks.
Sequence: steps happen in order, one after another.
Selection: a decision chooses which steps to do (if ... then ... else).
Iteration: steps are repeated (a loop).
Sequence: steps happen in order, one after another.
Selection: a decision chooses which steps to do (if ... then ... else).
Iteration: steps are repeated (a loop).
Flowchart symbols
Following an algorithm
Algorithm: INPUT a number. Double it. IF the result is more than 10, subtract 4. OUTPUT the result.
Input 3: double = 6. 6 is not more than 10. Output 6.
Input 7: double = 14. 14 is more than 10, so 14 - 4. Output 10.
Input 3: double = 6. 6 is not more than 10. Output 6.
Input 7: double = 14. 14 is more than 10, so 14 - 4. Output 10.
Use the algorithm: INPUT a number, double it, IF the result is more than 10 subtract 4, OUTPUT the result. What is output for 9?
- Double 9: 18.
- 18 is more than 10, so subtract 4: 14.
Answer: 14
Algorithms use sequence, selection and iteration. Flowcharts use a rounded box for start/stop, a rectangle for a process, a diamond for a decision and a parallelogram for input/output.
The interactive lesson includes the diagrams for this topic.
Check you have got it
Answer 6 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.