C Program to Check Leap Year or Not

Before going to the program first let us understand what is a Leap Year?

Leap Year:

          A Leap Year is a year that is exactly divisible by four, except for years that are exactly divisible by 100, but the century years are leap years if they are exactly divisible by 400.

Example: The century years like 1600, 2000 and 2400 are Leap Years since they are divisible by 400.

The century years like 1700, 1900 and 2100 are Not Leap Years since they are not divisible by 400.

The years like 2016, 2020 and 2024 are Leap Years since they are divisible by 4 but not divisible by 100.

The years like 2017, 2021 and 2029 are not Leap Years since they are not divisible by 4.

Program code to Check Leap Year or Not:


#include<stdio.h>
#include<conio.h>

void main()
{
    int year;
    clrscr();

    printf ("\n Enter a year: ");
    scanf ("%d", &year);

    // If-Else-If Conditions to Check Leap Year or Not
    if (year%400 == 0)
        printf("\n It is a LEAP YEAR.");
    else if (year%4==0 && year%100!=0)
        printf("\n It is a LEAP YEAR.");
    else
        printf ("\n It is Not a LEAP YEAR.");

    getch();
}

Output:

leap year

leap year

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *