#include <stdio.h>
int leap_yr(int);
int main(void)
{
int year, yes;
printf("\n Enter the Year: ");
scanf("%d",&year);
yes=leap_yr(year);
if(yes)
printf("\n It is a leap year");
else
printf("\n It is NOT a leap year");
return 0;
}
int leap_yr(int yr)
{
if((yr%4==0)&&( yr%100!=0)||yr%400 ==0)
return 1;
else
return 0;
}
Enter the Year: 2100
It is NOT a leap year
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.