Home Uncategorized Leap year in c

Leap year in c

SHARE

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 given year is a LEAP year\n”);
      else
         printf(“Given given year is not a LEAP year\n”);
   }
   else if(year%4==0)
      printf(“Given given year is a LEAP year\n”);
   else
      printf(“Given given year is not a LEAP year\n”);
   return 0;
}

Output :
i) Enter a year : 2100
Given given year is not a LEAP year
ii)Enter a number : 2020
Given given year is a LEAP year

Back to the programs list.