Program To Check Year is Leap Year or Not - C Program

Program To Check Year is Leap Year or Not

One year has the length of 365 days, 5 hours, 48 minutes and 45 seconds. This is hard to calculate with, so a normal year has been given 365 days and a leap year 366 days. In leap years, February 29th is added as leap day, which doesn't exist in a normal year. A leap year is every 4 years, but not every 100 years, then again every 400 years.

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

Output - Program to Check Leap Year

Enter a year: 2016      
2016 is a leap year. 
Compile and Run Online