- Category: Microsoft.NET

Leap year a year which have the 1 extra day from normal year, in leap year February have 29 days, in normal February have 28 day. Leap year has 366 days but normal year have 365.

To find the given year is the leap year, for that the algorithm is:

1. Year should be completely divided by 4 i.e. reminder should be zero.

2. AND, Year should not be completely divided by 100 i.e. reminder should not be zero.

3. OR, Year (Centaury) should be completely divided by 400 i.e. reminder should be zero.

We can find out the leap year in C# as follows for the given year.

private static string
FindLeapYear(int year)

{

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

{

return "Leap Year";

}

return "Not Leap Year";

}

Example
1:

Response.Write(FindLeapYear(1600));

OUTPUT:

Leap Year

Example 2:

Response.Write(FindLeapYear(1000));

OUTPUT:

Not Leap Year

Example 3:

Response.Write(FindLeapYear(2008));

OUTPUT:

Leap Year

## Comments (4)