How to find a leap year using C language?

CServer Side ProgrammingProgramming

Leap year is a year that consists of 366 days. For every four years, we will experience a leap year.

The logic we will implement to find whether the given year by the user through the console is a leap or not −

if (( year%400 == 0)|| (( year%4 == 0 ) &&( year%100 != 0)))

If this condition is satisfied, then the given year is a leap year. Otherwise, it is not.


Following is the C program to check leap year with the help of If condition −

 Live Demo

#include <stdio.h>
int main(){
   int year;
   printf("Enter any year you wish \n ");
   scanf(" %d ", &year);
   if (( year%400 == 0)|| (( year%4 == 0 ) &&( year%100 != 0)))
      printf("\n %d is a Leap Year. \n", year);
      printf("\n %d is not the Leap Year. \n", year);
   return 0;


When the above program is executed, it produces the following result −

Enter any year you wish
2045 is not the Leap Year.
Updated on 08-Mar-2021 10:09:07