Guides

How to draw a flowchart for an algorithm

Drawing an algorithm before you code it makes mistakes visible early. A flowchart forces you to decide what happens on every path, including the ones you would otherwise forget.

Start with input and output

Write down what goes in and what must come out. For finding the largest number in a list: the input is a list of numbers and the output is one number.

Break the logic into steps

  • Start: begin the flow.
  • Set up: create the variables you need, for example largest = first number.
  • Loop: for each remaining number in the list, do the comparison.
  • Decision: is this number larger than largest? If yes, update largest.
  • Output: show largest, then End.

Trace it with test values

Pick a small input and follow the arrows with a pen, writing down each variable as it changes. Then try the awkward cases: an empty list, a single item, equal values. Any path that leads nowhere is a bug in the plan.

Go from flowchart to running code

Choose Code flow when you create the diagram and use programming blocks with real input and output pins instead of plain shapes. You can then press Run code to execute the blocks, step through them and watch each variable change, before exporting JavaScript, Python or pseudocode.

Start a code flow