Check whether the enter year is leap or not
#include <stdio.h>
#include<conio.h>
int main()
{
int yr;
printf ("Enter a year \n");
scanf ("%d",&yr);
if (yr%4 == 0) {
if(yr%100 == 0) {
if(yr%400 == 0)
printf(" It is LEAP YEAR.");
else
printf(" It is NOT LEAP YEAR.");
}
else {
printf (" It is LEAP YEAR.");
}
}
else
printf(" It is NOT LEAP YEAR.");
return 0;
}
Output:-
Enter a year 2004
It is LEAP YEAR
Enter a year 2003
It is NOT LEAP YEAR
Comments
Post a Comment