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
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
| Shape | Symbol | Connections |
|---|---|---|
| Start | Terminator | → Read year y |
| Read year y | Input/output | → y divisible by 4? · ← Start |
| y divisible by 4? | Decision | → Common year(no), y divisible by 100?(yes) · ← Read year y |
| Common year | Process | → 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 year | Process | → 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 result | Input/output | → End · ← Leap year, Common year |
| End | Terminator | ← Print result |
Symbols used here
| Symbol | Meaning |
|---|---|
| Terminator | Where the flow starts or ends; a rounded rectangle. |
| Process | One action such as a calculation; a rectangle. |
| Decision | A question whose answer picks the next path; a diamond. |
| Input/output | Data comes in or goes out; a parallelogram. |
| Flow line | The order of steps, in the arrow direction. |
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