Diagram Desk

Leap year flowchart

A year is a leap year if divisible by 4 and not by 100, unless divisible by 400. Three rules become three decisions, and their order matters.

The diagram

StartRead year yy divisible by 4?Common yeary divisible by 100?Leap yeary divisible by 400?Print resultEndnoyesnoyesyesno
Flowchart · 9 shapes

Reading it step by step

  • 1. Start at 'Start'.
  • 2. 'Read year y' is an input or output. Next: 'y divisible by 4?'.
  • 3. Decide 'y divisible by 4?': if 'no', go to 'Common year'; if 'yes', go to 'y divisible by 100?'.
  • 4. 'Common year' is a processing step. Next: 'Print result'.
  • 5. 'Print result' is an input or output. Next: 'End'.
  • 6. End at 'End'.
  • 7. Decide 'y divisible by 100?': if 'no', go to 'Leap year'; if 'yes', go to 'y divisible by 400?'.
  • 8. 'Leap year' is a processing step. Next: 'Print result'.
  • 9. Decide 'y divisible by 400?': if 'yes', go to 'Leap year'; if 'no', go to 'Common year'.

Shape by shape

ShapeSymbolConnections
StartTerminator→ Read year y
Read year yInput/output→ y divisible by 4? · ← Start
y divisible by 4?Decision→ Common year(no), y divisible by 100?(yes) · ← Read year y
Common yearProcess→ Print result · ← y divisible by 4?, y divisible by 400?
y divisible by 100?Decision→ Leap year(no), y divisible by 400?(yes) · ← y divisible by 4?
Leap yearProcess→ Print result · ← y divisible by 100?, y divisible by 400?
y divisible by 400?Decision→ Leap year(yes), Common year(no) · ← y divisible by 100?
Print resultInput/output→ End · ← Leap year, Common year
EndTerminator← Print result

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.

# Leap year flowchart
flowchart TD
  s(["Start"])
  a[/"Read year y"/]
  b{"y divisible by 4?"}
  n["Common year"]
  c{"y divisible by 100?"}
  l["Leap year"]
  d{"y divisible by 400?"}
  o[/"Print result"/]
  z(["End"])
  s --> a
  a --> b
  b -->|no| n
  b -->|yes| c
  c -->|no| l
  c -->|yes| d
  d -->|yes| l
  d -->|no| n
  l --> o
  n --> o
  o --> z

More flowchart examples

All SeewolLabs tools