Computer Science Essentials, Unit 1, Lesson 7 of 7

Flowcharts

About 2 min to read, then 8 practice questions

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.

StartInput markmark ≥ 40?Output "Pass"Output "Fail"StopNoYes

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.

StartInput Nt = 0n = 1n > N?Output tStopt = t + nn = n + 1NoYes
  1. Input N = 3. Set t = 0 and n = 1.

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.

Practise this

8 questions, about 15 min

  • XP for each right first time
  • Fills in your course map

Sign in to keep your progress.

Start practising