Write a program that prompts the user to input a year and determine whether the year is a leap year or not.
Leap Years are any year that can be evenly divided by 4. A year that is evenly divisible by 100 is a leap year only if it is also evenly divisible by 400.
Example :
1992 | Leap Year |
2000 | Leap Year |
1900 | NOT a Leap Year |
1995 | NOT a Leap Year |
#include <stdio.h>
int main()
{
int year;
printf("Enter a year :");
scanf("%d", &year);
/* Determine whether the year is leap year */
if ((year % 4 == 0) && ((year % 400 == 0) || (year % 100 != 0)))
{
printf("A leap year");
}
else
{
printf("Not a leap year");
}
return 0;
}
Enter a year :2100
Not a leap year