Diagram Desk

Find the maximum: algorithm flowchart

Finds the largest of N numbers: take the first as the maximum, then compare the rest one by one. A classic loop exercise in programming classes.

The diagram

StartRead N numbersmax ← first number, i ← 2i ≤ N ?number i > max ?max ← number ii ← i + 1Print maxEndyesyesnono
Flowchart · 9 shapes

Reading it step by step

  • 1. Start at 'Start'.
  • 2. 'Read N numbers' is an input or output. Next: 'max ← first number, i ← 2'.
  • 3. 'max ← first number, i ← 2' is a processing step. Next: 'i ≤ N ?'.
  • 4. Decide 'i ≤ N ?': if 'yes', go to 'number i > max ?'; if 'no', go to 'Print max'.
  • 5. Decide 'number i > max ?': if 'yes', go to 'max ← number i'; if 'no', go to 'i ← i + 1'.
  • 6. 'max ← number i' is a processing step. Next: 'i ← i + 1'.
  • 7. 'i ← i + 1' is a processing step. Next: 'i ≤ N ?'.
  • 8. 'Print max' is an input or output. Next: 'End'.
  • 9. End at 'End'.

Shape by shape

ShapeSymbolConnections
StartTerminator→ Read N numbers
Read N numbersInput/output→ max ← first number, i ← 2 · ← Start
max ← first number, i ← 2Process→ i ≤ N ? · ← Read N numbers
i ≤ N ?Decision→ number i > max ?(yes), Print max(no) · ← max ← first number, i ← 2, i ← i + 1
number i > max ?Decision→ max ← number i(yes), i ← i + 1(no) · ← i ≤ N ?
max ← number iProcess→ i ← i + 1 · ← number i > max ?
i ← i + 1Process→ i ≤ N ? · ← max ← number i, number i > max ?
Print maxInput/output→ End · ← i ≤ N ?
EndTerminator← Print max

Symbols used here

SymbolMeaning
TerminatorWhere the flow starts or ends; a rounded rectangle.
ProcessOne action such as a calculation; a rectangle.
DecisionA question whose answer picks the next path; a diamond.
Input/outputData comes in or goes out; a parallelogram.
Flow lineThe order of steps, in the arrow direction.

All flowchart symbols and how to draw

Diagram text

Paste this text into the editor to get the same picture, then change the names to fit your own work.

# Find the maximum: algorithm flowchart
flowchart TD
  s(["Start"])
  a[/"Read N numbers"/]
  b["max ← first number, i ← 2"]
  c{"i ≤ N ?"}
  d{"number i > max ?"}
  e["max ← number i"]
  g["i ← i + 1"]
  h[/"Print max"/]
  z(["End"])
  s --> a
  a --> b
  b --> c
  c -->|yes| d
  d -->|yes| e
  e --> g
  d -->|no| g
  g --> c
  c -->|no| h
  h --> z

More flowchart examples

All SeewolLabs tools