# C Program to Check Leap Year

A year can be called a leap year if it is exactly divisible by 4 except for years ending with 00. but has an exception if a year is perfectly divisible by 400.

in short, Conditions for a year to be leap can be

• If a year is perfectly divisible by 4, 100 and 400 then it is a leap year.
• Also, If a year is perfectly divisible by 4 but not divisible by 100 then again it can be called as a leap year

Let’s move forward to write this logic in a C Program. To understand this code, We should know basic C programming.

### Program to Check Leap Year

```#include <stdio.h>
int main() {
int year;
printf("Enter a year: ");
scanf("%d",&year);
if(year%4 == 0) {
if( year%100 == 0) {
// year is divisible by 400, hence the year is a leap year
if ( year%400 == 0)
printf("%d is a leap year.", year);
else
printf("%d is not a leap year.", year);
}
else
printf("%d is a leap year.", year );
}
else
printf("%d is not a leap year.", year);
return 0;
}```

Output 1

```Enter a year: 2016
2016 is a leap year.```

Output 2

```Enter a year: 2012
2012 is a leap year.```
Subscribe
Notify of 