Flowcharts
The symbols and the arrows
A flowchart shows an algorithm as boxes joined by arrows.
Follow the arrows from Start until you reach Stop.
- Rounded rectangle (terminal): Start or Stop.
- Parallelogram: an input or an output, such as "Input mark" or "Output total".
- Rectangle: a process, an action or a calculation, such as "t = t + n".
- Diamond: a decision, a question with a yes or no answer. It has two arrows out, labelled Yes and No.
- Rectangle with double sides: a subroutine, another part of the program that runs and then comes back.
Decisions
This flowchart has one decision.
The arrow out of the diamond you follow depends on the answer to the question.
With mark = 40 the question "mark ≥ 40?" has the answer Yes, so the output is Pass. With mark = 39 the answer is No, so the output is Fail.
Check the boundary carefully: ≥ means greater than or equal to, so 40 itself goes down the Yes arrow.
Loops
A loop in a flowchart is an arrow that goes back up to an earlier box.
A decision decides when the flow leaves the loop.
- Input N = 3. Set t = 0 and n = 1.
- n > N? 1 > 3 is No, so go down: t = 0 + 1 = 1, n = 2, and back up.
- 2 > 3 is No: t = 1 + 2 = 3, n = 3, and back up.
- 3 > 3 is No: t = 3 + 3 = 6, n = 4, and back up.
- 4 > 3 is Yes, so the flow leaves the loop and outputs 6.
The decision was checked 4 times but the loop ran 3 times: there is always one more check than passes, because the last check is the one that ends the loop.
Completing and writing flowcharts
To fill a missing box, try each option with a small input and see which one does what the question says.
A missing decision is often a choice between > and ≥: try the value on the boundary.
When you draw a flowchart yourself:
- Start with Start and end with Stop.
- Put every input and output in a parallelogram, and every calculation in a rectangle.
- Label both arrows out of each decision, Yes and No.
- For a loop, draw the arrow back up to the box where the repeat begins.
Loading the question