Flowchart Updated 12/2/2026

Leap Year Flowchart

Leap year flowchart: test divisible by 400, then by 100, then by 4, in that order. With a trace table for 1900 (the year most answers get wrong), pseudocode, and tested Python, C and Java code.

leap yearflowchartnested ifdecisionsprogramming
8 nodes 10 connections

Study guide

Leap Year FlowchartStartRead yearyear % 400 == 0?year % 100 == 0?year % 4 == 0?Print "Leap year"Print "Not a leapyear"EndYesNoYesNoYesNo
Leap Year Flowchart. Source: https://www.chartcraft.dev/examples/leap-year-flowchart

What the leap year check flowchart shows

In the Gregorian calendar a year is a leap year if it divides by 4, except century years, which must also divide by 400. A leap year flowchart turns that rule into three diamonds, asked from the rarest case (400) to the most common (4).

Order is everything: ask the 400 question first and every later diamond can be a simple yes or no.

Leap year check flowchart, step by step

  1. terminator StartOne Start terminator opens the flowchart.
  2. input/output Read yearThe program reads the year, for example 1900, into year.
  3. decision year % 400 == 0?The rarest case comes first. Years like 1600, 2000 and 2400 divide by 400 and are always leap years.
  4. decision year % 100 == 0?Reached only if the year does not divide by 400. A century year that got here, like 1900 or 2100, is not a leap year.
  5. decision year % 4 == 0?Reached only by ordinary years. Divisible by 4 (2024) means leap; otherwise (2023) not.
  6. input/output Print "Leap year"Two arrows enter this box: from the 400 test and from the 4 test.
  7. input/output Print "Not a leap year"Also entered from two places: the 100 test and the 4 test.
  8. terminator EndBoth messages flow into one End terminator.

Dry run: trace table for year = 1900

Follow the flowchart with year = 1900. Each row is one diamond.

DiamondRemainderAnswerNext step
year % 400 == 0?1900 % 400 = 300NoGo to year % 100 == 0?
year % 100 == 0?1900 % 100 = 0YesPrint "Not a leap year"

1900 divides by 4, yet it was not a leap year. A flowchart that only tests by 4 gets this wrong.

Leap year check pseudocode

Pseudocode
READ year
IF year MOD 400 = 0 THEN
    PRINT "Leap year"
ELSE IF year MOD 100 = 0 THEN
    PRINT "Not a leap year"
ELSE IF year MOD 4 = 0 THEN
    PRINT "Leap year"
ELSE
    PRINT "Not a leap year"
ENDIF

Leap year check in Python, C and Java

Python
year = int(input())

if year % 400 == 0:
    leap = True
elif year % 100 == 0:
    leap = False
elif year % 4 == 0:
    leap = True
else:
    leap = False

if leap:
    print(year, "is a leap year")
else:
    print(year, "is not a leap year")
C
#include <stdio.h>

int main(void) {
    int year;
    scanf("%d", &year);

    int leap;
    if (year % 400 == 0) {
        leap = 1;
    } else if (year % 100 == 0) {
        leap = 0;
    } else if (year % 4 == 0) {
        leap = 1;
    } else {
        leap = 0;
    }

    if (leap) {
        printf("%d is a leap year\n", year);
    } else {
        printf("%d is not a leap year\n", year);
    }
    return 0;
}
Java
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int year = in.nextInt();

        boolean leap;
        if (year % 400 == 0) {
            leap = true;
        } else if (year % 100 == 0) {
            leap = false;
        } else if (year % 4 == 0) {
            leap = true;
        } else {
            leap = false;
        }

        if (leap) {
            System.out.println(year + " is a leap year");
        } else {
            System.out.println(year + " is not a leap year");
        }
    }
}
Input typed at the keyboard
1900
Output of all three programs
1900 is not a leap year

All three programs were compiled and run with the input 1900 before this page was published, and they print exactly the output shown. The if, else if chain follows the three diamonds in the same order.

Mistakes examiners see most

  • Testing only divisible by 4. That rule calls 1900 and 2100 leap years. It is the most common wrong answer in exams.
  • Putting the 4 test first. If year % 4 == 0? comes first and its Yes goes straight to Leap year, the century rule is never checked. Start with 400, then 100, then 4.
  • Mixing up the 100 branch. Divisible by 100 (and not by 400) means not leap. Some flowcharts send that Yes arrow to Leap year by habit.
  • Drawing four Print boxes. Not wrong, but messy. Two Print boxes with several arrows entering each keep the diagram readable. Review the if-else statement flowchart for how exits join.

Practice questions with worked answers

Q1 Trace the flowchart for 2000, 2024 and 2023.

2000: 2000 % 400 = 0, Yes, so Leap year (one diamond).

2024: 2024 % 400 = 24, No; 2024 % 100 = 24, No; 2024 % 4 = 0, Yes, so Leap year (three diamonds).

2023: the first two are No as well; 2023 % 4 = 3, No, so Not a leap year.

Q2 Write the whole rule as one condition that could go in a single diamond.
Condition
(year MOD 4 = 0 AND year MOD 100 <> 0) OR year MOD 400 = 0

Divisible by 4 but not by 100, or divisible by 400. It is shorter, but the three diamond version is easier to trace and to mark.

Q3 Why does the Gregorian calendar skip three leap days every 400 years?

A plain every-4-years rule gives 100 leap days per 400 years, which makes the calendar year a little too long on average. Dropping the century years 1700, 1800 and 1900 (but keeping 2000) removes 3 of them, leaving 97 leap years in each 400.

That is exactly what the 100 and 400 diamonds do.

Flowchart symbols used and why

SymbolShape to draw on paperWhere it appears hereWhy
TerminatorRounded boxStart and EndOne entry and one exit.
Input/outputParallelogramRead year and both Print boxesThey move data in or out of the program.
DecisionDiamondThe 400, 100 and 4 testsThree yes-or-no questions chained on their No exits.
Flow lineArrowEvery arrowArrows set the order, which matters most in this flowchart.

In the interactive diagram every step is a labelled card: the small word above each step names its kind (process, decision or data). When you draw this flowchart by hand, use the standard shapes in the table. The full list is on the flowchart symbols page.

Make your own version

Each link opens the editor with a prompt already filled in. Change the wording, then generate your own flowchart.

How can I use this flowchart?

Download the Leap Year Flowchart as a PNG or SVG, or open it in the studio to edit your own copy. To draw a similar flowchart from a description, use the flowchart generator; for notation and a step-by-step walkthrough, read how to make a flowchart; and browse more flowchart examples for related layouts.

Try the studio with your own description.

Type any system, process, or schema in plain English. ChartCraft will draw it in seconds.