#include<stdio.h>
int main()
{
int year, rem_4,rem_100,rem_400;
printf("Enter the year to be tested:");
scanf("%d", &year);
rem_4 = year % 4;
rem_100 = year % 100;
rem_400 = year % 400;
if( (rem_4 == 0 && rem_100 != 0) || rem_400 == 0)
printf("It is a leap year.\n");
else
printf("It is not a leap year.\n");
getch();
return 0;
}
<b>Output 1:</b>
Enter the year to be tested:2100
It is not a leap year.
<b>Output 2:</b>
Enter the year to be tested:2012
It is 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.