C# Examples
C# ExamplesPrograms with output

C# Program to Check Year is a Leap Year or Not


Example:
using System;

class LeapYear
{
    static void Main(string[] args)
    {
        int year;
        Console.WriteLine("Enter the Year in Four Digits: ");
        year = Convert.ToInt32(Console.ReadLine());
            
        if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
        {
            Console.WriteLine("{0} is a Leap Year", year);
        }
        else
        {
            Console.WriteLine("{0} is not a Leap Year", year);
        }
            
        Console.ReadLine();
    }
}
Output:
Enter the Year in Four Digits:
2021
2021 is not a Leap Year

Share this page on:

Was this page helpful ?

Let us know how we did!

Subscribe Email Updates

to get latest update