Monday 12 June 2017

C Program to check whether an year is a Leap Year or not.




This is a C program which checks the input year for Leap year.

A year is said to be a leap year, if it exactly divisible by 4 but not for century years(years ending with 00) and also an year is called Leap Year when it is exactly divisible by 400.




PROGRAM : 

#include <stdio.h>
#include <stdlib.h>

void checkLeapYear(int);
int main()
{
    int input_year;
    printf("\n Enter any year : ");
    scanf("%d",&input_year);
    checkLeapYear(input_year);
    getch();
    return 0;
}

void checkLeapYear(int year)
{
    int r1,r2;
    r1 = year%4 ;
    r2 = year%100;
    if((r1 == 0) && (r2!=0) || year%400 == 0)
    {
        printf("\n The given year %d is a LEAP Year",year);
    }
    else
    {
        printf("\n The given year %d is NOT a Leap Year",year);
    }
}

Output:

C Program to check whether an year is a Leap Year or not

C Program to check whether an year is a Leap Year or not