Please any one give Explanation

Posted by Gow.Net under C# on 3/6/2012 | Points: 10 | Views : 752 | Status : [Member] | Replies : 3
public int checkyear(int year)
{
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
{
Console.WriteLine(year + "LeapYear");
return 1;
}
else
{
Console.WriteLine(year + "Not LeapYear");
return 0;
}
}


i need explanation for
year % 4 == 0
year % 100 != 0
year % 400 == 0

how to execute and how work that coding

gowthaman8870226416


Responses

Posted by: Neer on: 3/6/2012 [Member] Starter | Points: 25

Up
0
Down
if ((year % 4 == 0 && year % 100 != 0 )&& year % 400 == 0)

if (year % 4 == 0)
{
if (year % 100 == 0)
{
if (year % 400 == 0)
{
is_leap_year
}
else
{ not_leap_year }
}
else
{ is_leap_year }
}
else
{ not_leap_year }

-Neer

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 3/6/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi

if (year % 4 == 0)
{
if (year % 100 != 0)
{
if (year % 400 == 0)
{
year is leap year;
}
else
{
year is not leap year;
}
}
else
{
year is not leap year;
}
}
else
{
year is not leap year;
}


Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 3/8/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Check this link
http://www.roseindia.net/java/beginners/Leapyear.shtml
http://www.go4expert.com/forums/showthread.php?t=2099
http://www.leonmeijer.nl/archive/2008/02/29/68.aspx

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response