C program to find whether the given year is Leap year or not.

Problem statement

Write a program to take a year as input and check it is leap year or not.

What years are leap year?

We know that in common year there are 365 days in a year.
But a year which has 366 days is called leap year. Means in a leap year there is one extra day.
There are 3 criteria to identify leap year:

  • The year can be evenly divided by 4
  • If the year can be evenly divided by 100, it is NOT a leap year, unless;
  • The year is also evenly divisible by 400. Then it is a leap year.

This means that, the years 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years.

Program to check given year is leap year or not

Output

Explanation

First of all, we take a year as input from user.
Then we check the given year is divided by 100 or not.
If it is divided by 100 then also check, it is divisible by 400 or not.
If it is divisible by 400 then it is a leap year, else, not a leap year.

Also, if a given year is not divisible by 100, then check it is divisible by 4 or not?
If it is divisible by 4 then it is a leap year if not then it is not.

Help others by sharing the content!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.