Home C Language Basic C Programs Leap Year

Leap Year

Write a C Program to Find Whether the Given Year is a Leap Year or not.

#include<stdio.h>

int main()

{

   int year;

   printf(“Enter a year :”);

   scanf(“%d”,&year);

   if(year%100==0)

   {

      if(year%400==0)

         printf(“Given year is a LEAP year\n”);

      else

         printf(“Given year is a NON-LEAP year\n”);

   }

   else if(year%4==0)

      printf(“Given year is a LEAP year\n”);

   else

      printf(“Given year is a NON-LEAP year\n”);

   return 0;

}

Output:

i) Enter a year : 2100

Given year is a NON-LEAP year

ii)Enter a number : 2020

Given year is a LEAP year