C# Program To Check Year is Leap Year or Not - C# Program

C# Program To Check Year is Leap Year or Not

One year has the length of 365 days, 5 hours, 48 minutes and 45 seconds. This is hard to calculate with, so a normal year has been given 365 days and a leap year 366 days. In leap years, February 29th is added as leap day, which doesn't exist in a normal year. A leap year is every 4 years, but not every 100 years, then again every 400 years.

using System;
namespace ProgramToCheckLeapYear
{
    class Program
    {
        static void Main(string[] args)
        {
            int year;
            Console.Write("Enter the Year :");
            year = Convert.ToInt32(Console.ReadLine());
            if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
                Console.WriteLine("Year is Leap Year");
            else
                Console.WriteLine("Year is not a Leap Year");


            Console.ReadKey();
        }
    }
}

Output - C# Program To Check Year is Leap Year or Not

Enter the Year : 2004
Year is Leap Year