- Computers and coding
- Classes 6-8
- 5 min read
Flowcharts: drawing a plan
Draw a flowchart with start, step, decision and end shapes, follow the arrows, and plan any task before writing code.
Let us begin
The big idea
Before a programmer writes code, they often draw the plan as a picture. That picture is called a flowchart. You can draw one with just paper and a pencil, and it works for recipes, games and sums too.
A flowchart uses a few simple shapes joined by arrows. A rounded box (oval) marks Start and End. A rectangle is a step: something to do, like "add 5" or "boil the water". A parallelogram is used for input or output, like "ask for a number" or "print the answer".
A diamond is a decision. It asks a yes or no question, such as "is the number bigger than 10?". Two arrows leave a diamond: one labelled Yes and one labelled No. Every other shape has exactly one arrow leaving it.
To follow a flowchart, put your finger on Start and move along the arrows. At each diamond, answer the question and take the matching arrow. You stop when you reach End. If an arrow goes back up to an earlier box, that is a loop: the same steps repeat until the decision says to stop.
A good flowchart has one Start, at least one End, arrows that all point somewhere, and short clear words in every box. If you get lost while following it, the chart needs fixing before anyone writes code from it.
Worked examples
See how it works
Crossing the road
Start. Step: stand at the kerb and look right, left, right. Decision: is the road clear? If No, go back to the look step. If Yes, step: walk straight across. End. The No arrow makes a loop: you keep looking until it is safe.
Is the number even?
Start. Input: take a number N. Decision: does N divided by 2 leave remainder 0? If Yes, output "even". If No, output "odd". End. Try N = 14: 14 divided by 2 is 7 remainder 0, so the Yes arrow is taken and the output is "even".
Counting to 5
Start. Step: set count to 1. Output: print count. Decision: is count equal to 5? If No, step: add 1 to count, then go back to the print box. If Yes, End. Following it prints 1, 2, 3, 4, 5 and then stops.
Try it at home
Flowchart your morning
You will need
- Two or three sheets of paper
- A pencil and an eraser
- A coin or a small stone to use as a marker
What to do
- List the first six things you do after waking up, for example brush teeth, bathe, eat breakfast, pack bag.
- Draw an oval for Start, then a rectangle for each thing, joined by arrows going down.
- Add one diamond with a question, such as "is it raining?", and give it a Yes arrow (take an umbrella) and a No arrow (go straight to the bag).
- Finish with an End oval. Now place the coin on Start and move it along the arrows, saying each step aloud.
- Ask a family member to follow your chart with the coin. If they get stuck, fix the chart.
Practice sheet
Check what you learned
Practice sheet: Flowcharts: drawing a plan (Classes 6-8, Computers and coding)
- Which flowchart shape is used for Start and End?
- Which shape asks a yes or no question?
- How many arrows leave a decision diamond?
- In the "is the number even?" flowchart, which arrow is taken for N = 9?
- What does it mean when an arrow goes back up to an earlier box?
- Which shape would you use for "print the total"?
- In the counting flowchart, what is printed if the decision is "is count equal to 3?" instead of 5?
- Name one thing that is wrong if a flowchart has no End shape.
- Draw in words a two-step flowchart for making tea with one decision in it.
- Why is it useful to draw a flowchart before writing a program?
Answer key
Answers: Flowcharts: drawing a plan
- A rounded box (oval).
- The diamond.
- Two: one for Yes and one for No.
- The No arrow, because 9 divided by 2 leaves remainder 1, so the output is "odd".
- It is a loop: the earlier steps repeat until the decision sends you another way.
- A parallelogram (slanted box), because printing is output.
- 1, 2, 3 and then it stops.
- Anyone following it can never finish; every path must reach an End.
- Start, boil water, add tea leaves, decision: do you want milk? Yes: add milk, No: skip, pour, End. (Any sensible answer with a diamond is correct.)
- You can see mistakes and missing steps early, and others can understand the plan before any code is written.
