# Leap year program in C

Leap year program in C to check if a year is a leap year or not, a leap year is one that has 366 days, and the extra day is in the month of February (29th February).

Condition or logic for a leap year: A year that is exactly divisible by four is a leap year, except for a year that is exactly divisible by 100 but, the year is a leap year if it is exactly divisible by 400. Read more about a Leap year. The program is based on the Gregorian Calendar.

## Leap year C program

#include <stdio.h>

int main()
{
int year;

printf("Enter a year to check if it's a leap year\n");
scanf("%d", &year);

if (year%400 == 0) // Exactly divisible by 400, e.g., 1600, 2000
printf("%d is a leap year.\n", year);
else if (year%100 == 0) // Exactly divisible by 100 and not by 400, e.g., 1900, 2100
printf("%d isn't a leap year.\n", year);
else if (year%4 == 0) // Exactly divisible by 4 and neither by 100 nor 400, e.g., 2016, 2020
printf("%d is a leap year.\n", year);
else // Not divisible by 4 or 100 or 400, e.g., 2017, 2018, 2019
printf("%d isn't a leap year.\n", year);

return 0;
}

Output of program: