Given year is leap year or not ? using C
A leap year is a year that occurs once every four years. Based on the Gregorian calendar. Leap year is exactly divisible by 4 except for century years (years ending with 00). The century year is a leap year only if it is perfectly divisible by 400 and it is not exactly divisible by 100
For example,
- 1997 is not a leap year
- 2004 is a leap year
- 2016 is a leap year
// TO FIND GIVEN YEAR IS LEAP YEAR OR NOT
#include <stdio.h>
int main()
{
int y;
printf("Enter the year : ");
scanf("%d",&y);
if(y%400==0) //leap year
{
printf("%d is leap year",y);
}
else
if(y%100==0) //Not leap year
{
printf("%d not leap year",y);
}
else
if(y%4==0) //leap year
{
printf("%d is leap year",y);
}
else
{
printf("%d is not leap year",y);
}
return 0;
}
Output 1:
Enter a year: 1993
1993 is not a leap year.
Enter a year: 2008
2008 is a leap year.