C PROGRAM TO FIND LEAP YEAR:
What is leap year?
Leap year is a year which has 366 days. Leap year occurs once every 4 years.
How to find whether a year is leap year or not using a C program?
- A year which can be exactly divisable by 4 except century years is called leap year.
- Century year means the year which ends with 00. Century year also can be a leap year if it is exactly divisable by 400.
vim leapyear.c
#include <stdio.h>
int main()
{
int year;
printf("Please enter a year to check whether it is a leap year or not: ");
scanf("%d", &year);
if (year % 400 == 0)
{
printf("%d is a leap year.\n", year);
}
else if (year % 100 == 0)
{
printf("%d is a leap year.\n", year);
}
else if (year % 4 == 0)
{
printf("%d is a leap year.\n", year);
}
else
{
printf("%d is not a leap year.\n", year);
}
return 0;
}