C Program to Check Leap Year  

Leap year contains leap day Feb 29. A leap year is a year which is exactly divisible by 4 except for century years (years ends with 00). The century year is a leap year only when it perfectly divisible by 400.

0 371 Technology | C-Programming
Tue Dec 25 , 2018

In this article given program checks whether the input year is a leap year or not.

Example

C Program to Check the Leap Year


#include <stdio.h>

int main() 
{
    int year;

    printf("Enter a year: ");
    scanf("%d",&year);
    
    if (year%400 == 0)      
    printf("%d is a leap year", year);  
        
    else if (year%100 == 0)      
    printf("%d is not a leap year", year); 
         
    else if (year%4 == 0 )      
    printf("%d is a leap year", year);
    
    else      
    printf("%d is not a leap year", year);      

    return 0;
}


Outputs

Enter a year: 2018
2018 is not a leap year
Enter a year: 1900
1900 is not a leap year
Enter a year: 2020
2020 is a leap year


Subscribe & Get Regular Updates On Your E-mail