Check if the Year is a Leap Year or Not in C#

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using System.Threading.Tasks;  
  6. namespace ConsoleApplication1  
  7. {  
  8.     class CalcAvgPerc  
  9.     {  
  10.         static void Main(string[] args)  
  11.         {  
  12.             int year;  
  13.             Console.WriteLine("Enter the year you want to check is Leap or not");  
  14.             year = int.Parse(Console.ReadLine());  
  15.             Console.WriteLine("Checking.....");  
  16.             System.Threading.Thread.Sleep(2000);  
  17.             if (year % 400 == 0)  
  18.                 Console.WriteLine("Year {0} is Leap", year);  
  19.             else if (year % 100 == 0)  
  20.                 Console.WriteLine("Year {0} is not a Leap Year", year);  
  21.             else if (year % 4 == 0)  
  22.                 Console.WriteLine("Year {0} is a Leap Year", year);  
  23.             else  
  24.                 Console.WriteLine("Year {0} is not a Leap Year", year);  
  25.             Console.ReadKey();  
  26.         }  
  27.     }