C Program to Check Leap Year

C Program to Check Leap Year

How can we check even or odd number in C? Leap year is that year which has 366 days, and the extra day is in the month of February (29th)

Leap year in C :



#include<stdio.h>

int main()
{
  int year;
 
  printf("Enter a year to check if it's a leap year : ");
  scanf("%d", &year);
 
  if (year%400 == 0)
    printf("%d is a leap year.\n", year);
  else if (year%100 == 0) 
    printf("%d isn't a leap year.\n", year);
  else if (year%4 == 0)
    printf("%d is a leap year.\n", year);
  else 
    printf("%d isn't a leap year.\n", year);  
   
  return 0;
}
         

Output :