There are 356 days in a common year while a leap year has 366 days. February 29 is a date Which occurs once after every four years and is called leap day. February 29 is included to the leap year calendar as leap day because the Earth does not complete its orbit around the sun inaccurately 365 days.

Check Leap Year using C#

Here is a simple code example in C# to Check Whether the Entered Year is a Leap Year or Not.

public static void Main()
	{
		int inputYear;
		Console.WriteLine("Enter Any Year To Check Whether the Entered Year is a Leap Year or Not");
		AnyYear=int.Parse(Console.ReadLine());
		if (inputYear % 400 == 0 || (inputYear % 4 == 0 && inputYear % 100 != 0 ))
		{
			Console.WriteLine("Is Leap Year : {0}",inputYear);
		}
		else
		{
			Console.WriteLine("Not a Leap Year : {0}",inputYear);
		}
		
		Console.ReadLine();
	}

Output:

Enter Any Year To Check Whether the Entered Year is a Leap Year or Not

1999

Not a Leap Year : 1999

Code explanation

We can find the leap year in C# using the below algorithm. This algorithm determines Whether the Entered Year is a Leap Year or Not

if (the year isn’t divided by 4) then (it is a typical(common) year)

else if (the year isn’t divided by 100) then (it is a leap year)

else if (the year isn’t divided by 400) then (Typical(common) year)

else (leap year)

Recommended Reading

Last modified: April 13, 2019