### 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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#include<stdio.h> int main() { int i=1, num; printf("Enter the number: \t"); scanf("%d", &num); if(num % 100 == 0) { if(num % 400 == 0) { printf("%d is leap year", num); } else { printf("%d is not leap year", num); } } else { if(num % 4 == 0) { printf("%d is leap year", num); } else { printf("%d is not leap year", num); } } } |

**Output**

1 2 3 |
Enter the number: 1800 1800 is not leap year |

1 2 3 |
Enter the number: 2016 2016 is leap year |

**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.

### Ankit Wasankar

Senior Java Developer

Java 11 | Microservices | Reactjs | SQL