C Program to Check if the Year is a Leap Year or Not

Check if a Year is a Leap Year or Not in C

Given an integer input for an year, the objective is to check whether the given integer input represents a Leap year or not. In order to do so we’ll check for two conditions, any year to be a leap year must satisfy either of them.

Example

Input : 2020

Output : It's a Leap Year

Flow Diagram:-

Leap year or not.png

Code:-

  • step 1: Start

  • step 2: Read year

  • step 3: if year%4=0 and year%100!=0 or if year%4=0 and year%400=0 then go to step 4
    else go to step5

  • step 4: print a leap year

  • step 5: print not a leap year

  • step 6: Stop

Algorithm:-

Code:-

#include <stdio.h>
int main ()
{
    int year;
    scanf("%d",&year);
    
    if(year % 400 == 0)
        printf("%d is a Leap Year",year);
        
    else if(year % 4 == 0  && year % 100 != 0)
        printf("%d is a Leap Year",year);
        
    else
        printf("%d is not a Leap Year",year);
    
    return 0;
}

Output:-

2100

2100 is not a Leap Year