#include<stdio.h>
int main()
{
Int Y;
printf(
"Enter
a year: " );
scanf(
"%d"
,&Y);
if(Y%4==0
&& Y%100!=0)
printf( "\nLeap Year"
);
else
if(Y%400==0)
printf( "\nLeap Year"
);
else
printf( "\nNot Leap Year"
);
return 0;
}
|
is it need to write ( else if(Y%400==0)) ?\
ReplyDeleteYes... That s the required conditions ....for example yr 1700 is not a leap year... though it is divided by 4 as well as 100.... Bt not divided by 400
Deletethis needs only y%4==0 .you make it complicated
ReplyDeleteNo bro....that is the required conditions....refer any book
DeleteThis comment has been removed by the author.
ReplyDeletecomplicated....would work the same at year%4==0
ReplyDelete