I really don't understand the logic of performing:-
if(num%400==0)
stmts;
else if(num%100==0)
stmts;
for testing a leap year. Isn't it enough for just finding modulus of 100?
Thanks in advance!!
I really don't understand the logic of performing:-
if(num%400==0)
stmts;
else if(num%100==0)
stmts;
for testing a leap year. Isn't it enough for just finding modulus of 100?
Thanks in advance!!
The logic behind whether a year is leap or not:
So, the condition would be
if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
printf("Year is a leap year\n");
else
printf("Not a leap year\n");
No. Every century year is NOT a leap year. Only those divisible by 400 are.