This C# Program Checks Whether the Entered Year is a 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.
Here is source code of the C# Program to Check Whether the Entered Year is a Leap Year or Not.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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("{0} is Leap Year",year); else Console.WriteLine("{0} is not a Leap Year",year); Console.ReadLine(); } |
Output: