Check for leap year - C Program
C program to check if year is leap or not.
Solution:
This program determines year is leap year or not. Following are the rules for checking leap year.
i) If year is divisible by 400 then it is a leap year.
e.g. - 1600, 2000 are leap year but 1500, 1700 are not leap year.
ii) If year is not divisible by 400 and 100 but divisible by 4 then that year is leap year.
#include<stdio.h>
int main()
{
int yr;
printf("Enter Any Year: ");
scanf("%d",&yr);
if(((yr%4==0)&&(yr%100!=0)) || (yr%400)==0)
printf("%d is a Leap Year",yr);
else
printf("\n%d is NOT a Leap Year.",yr);
return 0;
}
Output: