Flowchart examples · Programming and algorithms

Leap year flowchart

The Gregorian rule as three decisions: divisible by 4, then by 100, then by 400. Traced for 2024, 1900 and 2000.

Use this template Describe your own version

Leap year check

Leap year checkYesNoYesNoYesNoStartRead year YY mod 4 = 0?Y mod 100 = 0?Y mod 400 = 0?Print leap yearPrint not a leap yearEnd
Use this template →Opens this exact diagram in the editor, every box and arrow editable. Free account; no AI credits used.

A worked example to adapt. Rename steps, add branches and owners to match how your team actually works.

Edit the steps to match your process. The free preview (no sign-up) drafts up to 8 main steps; add branches and the remaining steps in the editor.
Mermaid source for this diagram
flowchart TD
  s(["Start"])
  in[/"Read year Y"/]
  d1{"Y mod 4 = 0?"}
  d2{"Y mod 100 = 0?"}
  d3{"Y mod 400 = 0?"}
  ly[/"Print leap year"/]
  nl[/"Print not a leap year"/]
  e(["End"])
  s --> in
  in --> d1
  d1 -->|Yes| d2
  d1 -->|No| nl
  d2 -->|Yes| d3
  d2 -->|No| ly
  d3 -->|Yes| ly
  d3 -->|No| nl
  ly --> e
  nl --> e

Paste into any Markdown tool that renders Mermaid, such as GitHub.

About this leap year flowchart

Under the Gregorian calendar a year is a leap year if it is divisible by 4, except that years divisible by 100 are not leap years unless they are also divisible by 400. That is why 2024 and 2000 were leap years and 1900 was not.

The rule has three conditions and one exception to an exception, which makes it a good exercise in ordering decisions. The flowchart checks the most common case first: a year not divisible by 4 is never a leap year and exits immediately. Only years divisible by 4 go on to the century test, and only century years go on to the 400 test.

Students often draw the three conditions in the wrong order, for example testing 400 last on the wrong branch, which marks 1900 as a leap year. Tracing the three test years below catches every common mistake.

Step by step

  1. Input. Read the year Y.
  2. Divisible by 4?. If not, Y is not a leap year. Most years exit here.
  3. Divisible by 100?. If Y is divisible by 4 but not by 100 (like 2024), it is a leap year.
  4. Divisible by 400?. Century years are leap years only if divisible by 400: 2000 yes, 1900 no.
  5. Output and end. Print the result. Both outputs lead to the end oval.

How to make it in flow-chart.io

  1. Start from the example. Press "Use this template" to open this exact leap year flowchart in the editor, or edit the text in the generator box and press Generate for a free preview without signing up.
  2. Match your program. Rename the input, process and output boxes so they use the same variable names as your code. Keep one action per box.
  3. Check every branch. Trace each diamond with a test value for the Yes exit and one for the No exit, and make sure both reach the end oval.
  4. Share or export. Share a read-only view link with a classmate or reviewer. Downloads as PNG, SVG or PDF are part of Flow Pro (see pricing).

Tips

Frequently asked questions

What is the rule for a leap year?
Divisible by 4, except years divisible by 100, which are leap years only if also divisible by 400. This is the Gregorian calendar rule.
Why is 1900 not a leap year?
It is divisible by 4 and by 100 but not by 400, so the century exception applies.
Can the flowchart be drawn with one decision?
Yes, with a combined condition: (Y mod 4 = 0 and Y mod 100 ≠ 0) or Y mod 400 = 0. Teachers often ask for the three-decision version because it shows the logic step by step.
Which order should the checks go in?
Either 4, then 100, then 400 as drawn here, or 400 first, then 100, then 4. Both are correct if each branch leads to the right output; trace 1900 and 2000 to be sure.
Can I open this flowchart in an editor?
Yes. Press Use this template to open it in the editor with a free account; every box is editable.

Related

Flowchart to check even or odd numberFlowchart to find the largest of three numbersPrime number flowchartFactorial flowchartFlowchart symbolsHow to make a flowchartText to flowchart toolAll flowchart examples

Build it from your own words

Describe your process and get an editable diagram. Free to build and edit; Flow Pro adds downloads and unlimited projects.

Start free See pricing