C Program to Check Whether a Year is Leap Year or not

In this program, you'll learn to check given year is Leap Year or not. A year is leap if it divisible by 4. A year is a leap year if it satisfy following conditions: 1) It is evenly divisible by 100 2) If it is divisible by 100, then it should also be divisible by 400 3) Except this, all other years evenly divisible by 4 are leap years.



Source Code
#include<stdio.h>

int main()
{
    int year;
    printf("Enter the year: ");
    scanf("%d",&year);

    if(((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))
    {
        printf("Year %d is a Leap year",year);
    }
    else
    {
        printf("Year %d is not a Leap year",year);
    }
    return 0;
}
Output
Enter the year: 2016
Year 2016 is a Leap year

Enter the year: 2050
Year 2050 is not a Leap year