Algorithm: largest of three numbers flowchart

Programming courses use this exercise to teach nested decisions. Each comparison is a diamond, the read and print steps are parallelograms (input/output), and there is exactly one Start and one End.

How to write steps
  • One step per line. Lines connect top to bottom.
  • End a line with ? to make a decision. Indent the answers under it: yes: Ship it, no: Refund.
  • Indent more lines under an answer to continue that branch.
  • -> Step name jumps back to an earlier step (a loop). no -> Step name works inside a decision.
  • Start, End, Done or Stop become rounded start/end shapes.
  • Shape tags: [input] [output] [doc] [db] [sub] [manual] [delay].
  • lane: Sales on its own line puts the next steps in a swimlane.
  • Or paste Mermaid code starting with flowchart TD. It’s detected automatically.

Mermaid code for this chart
flowchart TD
  n1(["Start"])
  n2[/"Read A, B and C"/]
  n3{"Is A greater than B?"}
  n4{"Is A greater than C?"}
  n5[/"Print A"/]
  n6[/"Print C"/]
  n7{"Is B greater than C?"}
  n8[/"Print B"/]
  n9(["End"])
  n1 --> n2
  n2 --> n3
  n3 -->|"yes"| n4
  n4 -->|"yes"| n5
  n4 -->|"no"| n6
  n3 -->|"no"| n7
  n7 -->|"yes"| n8
  n7 -->|"no"| n6
  n5 --> n9
  n6 --> n9
  n8 --> n9
  n6 --> n9

The steps as text

This is the source of the chart above, so the template is readable even without the diagram.

Start
[input] Read A, B and C
Is A greater than B?
  yes: Is A greater than C?
    yes: [output] Print A
    no: [output] Print C
  no: Is B greater than C?
    yes: [output] Print B
    no: [output] Print C
End

More flowchart examples

Questions people ask

How do I edit this algorithm: largest of three numbers flowchart?

Change the text in the editor. Each line is a step, lines ending in “?” are decisions, and indented lines are the answers. The chart redraws as you type and is saved in your browser.

Can I download it?

Yes: PNG for documents and slides, SVG for sharp printing, or Mermaid code for GitHub, Notion and Obsidian.