C Program to Check Leap Year

This C program checks whether given year is leap year or not. A leap year is a year which is divisible by 4 and not divisible by 100 OR it a divisible by 400.

C Program to Check Given Year is Leap Year or Not

/* C code to check whether given year is leap year or not */


int main()
    int year;
    printf("\n Enter the year:-");

    if (year%4==0 && year%100!=0)
        printf("\n The year %d leap year \n \n",y);
        printf("\n The year %d not leap year. \n \n", year);

    return 0;


 Enter the year:-2012

 The year 2012 leap year.


Accept the year from user store it into variable year. Use control statement if to check if given year
Case 1: is divisible by 400 OR Case 2: is divisible by 4 and not divisible by 100
by using modulus operator ( % ) in C. If any one of above two cases is true then the year is a leap year.

C program to check leap year using Function

/* Aim: Write a function for the following function prototype
void Leap(int l) */ 


void Leap(int l);  // Leap Function Prototype

void main()
	int l;
	printf("\n Enter any year:- ");


// Leap Function

void Leap(int l)
		printf("\n %d is leap year \n \n",l);
		printf("\n %d is not leap year \n \n",l);



 Enter any year:- 2012

 2012 is leap year