Course 7.1Lesson 3 of 3
A flowchart shows the steps of an algorithm with standard shapes joined by arrows. You learn the six symbols of the syllabus, read flowcharts with decisions and loops, work out their outputs, state their purpose and draw your own.
Try the code and the simulations beside the lesson.
An algorithm is a set of steps that solves a problem. A flowchart draws those steps as shapes joined by arrows. You start at START, follow the arrows, do what each shape says, and finish at STOP. Because the shapes are standard, any programmer can read your flowchart.
These are the symbols the Cambridge IGCSE syllabus uses. Use exactly these.
Total ← 0.INPUT Number or OUTPUT Total.Write the steps precisely. Temp > 30 is right. "Temp is greater than 30" is not accepted in the exam, because it is not precise.
This flowchart inputs a temperature. The decision asks Temp > 30?. If the answer is Yes, the output is "Hot". If it is No, the output is "Mild". Only one path is followed each time. Choosing between paths like this is called selection.
Try it. For an input of the output is "Hot". For the answer to 30 > 30 is No, so the output is "Mild". A value on the edge of a decision is worth checking every time.
In this flowchart a flow line goes back up to an earlier shape. That makes a loop: the steps inside it repeat. Follow it with the inputs , and .
Total ← 0.Total becomes . Back to the input.Total becomes . Back to the input.The is a signal to stop, not a number to add. A value used like this is often called a rogue value.
The purpose of the algorithm. The syllabus asks you to state what a given algorithm is for, and to describe its processes. For this flowchart: "It inputs numbers until a is input, adds them up, and outputs the total." A good purpose statement says what goes in, what is worked out and what comes out.
Here is the same algorithm in pseudocode. You learn to write pseudocode in the next course.
Total ← 0
INPUT Number
WHILE Number <> 0 DO
Total ← Total + Number
INPUT Number
ENDWHILE
OUTPUT TotalThe grey block marked pseudocode is written in the exam style. It does not run on the site. The box marked Python below it is the same algorithm in Python, and that one runs. The Python program follows the loop flowchart step by step. The inputs are in a list. You met while loops in the Python Foundations chapter "Loops: Repeat Until with while".
Count > 10, not "Count is more than 10".Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
OUTPUT "Hello"?SortScores. What does this box mean?Every lesson is open to read. Enrolling also lets you:
Log in to join the discussion.
Loading…
This lesson is free to read. Enroll free to keep your place in the course.