AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Reading flowcharts

Week 2 · Unit 1: Go with the flow · 3 lessons
2

What will happen?

Computing 6: Unit 1, pp. 8–21
GoalPredict the outcome of a flowchart by finding its type, inputs, processes and outputs and by tracing it with test values.
New words
predict · to say what will happen before it happenstrace · to follow a flowchart step by step with real valuestest value · an input chosen so that you can check what a flowchart does
Explanation

You can predict what a flowchart will do without a computer. First find its type: linear, with a loop or with a decision. Then list the inputs, the processes and the outputs. Count the decisions, because they tell you how many different outcomes there can be. Then choose test values and trace the flowchart with each one. Write down what changes at every step. Choose test values that send you down every path, including values that sit right on the edge of a question.

Starttype your ageage below 12?yesnoshow: child ticketshow: adult ticketEnd
Worked examples
Age typedAge below 12?Shown
9yeschild ticket
12noadult ticket
40noadult ticket
The ticket flowchart is a decision flowchart. Its input is the age, its process is the comparison with 12 and its outputs are the two messages. It has two outcomes. Here it is traced with three test values. Notice that 12 is not below 12.
Startset coins to 0coins below 5?yesadd 2 coinsnoshow coinsEnd
Chen traces a flowchart with a loop. The coins start at 0. Each time round the loop adds 2 coins. The question is asked before every addition. The program stops when the answer is no and then shows the coins.
Coins nowBelow 5?What happens
0yesadd 2, now 2
2yesadd 2, now 4
4yesadd 2, now 6
6noshow 6
Chen’s trace table shows that the loop runs three times and the output is 6, not 5. The coins jump over 5, so the question is only answered no when they reach 6.
Class activity

Be the computer (no computer): ask a partner to write a flowchart on paper with one input, one decision and two outputs, for example ‘roll a die: is the number more than 3? yes: say Big, no: say Small’. Roll a real die six times. Each time, trace the flowchart with your finger and say the output out loud. Your partner checks you. Then swap jobs. Write down which test values you needed to visit both outputs. If you have a computer or tablet, you can use a die-rolling tool instead of a real die.

Practice
1
Say the type of this flowchart, its input and how many outcomes it has. What is shown for a mark of 10? What is shown for 9?
Starttype a mark out of 20mark 10 or more?yesnoshow: Passshow: Try againEnd
2
What is shown at the end of this flowchart?
Startset stars to 10stars above 4?yestake away 3 starsnoshow starsEnd
3
The ticket flowchart shows Child ticket if the age is below 12. Which two test values would check both paths, and why is 12 a good extra test value?
4
A flowchart takes a number, multiplies it by 3 and adds 1, then shows the result. Fill in the outputs.
Number typedShown
4?
10?
0?