Leap year is a year in which the day is 366 instead of 365 because there are 29 days in February month. We can find all the leap year by using the following C# program.
Program:
using System;
public class Program
{
public static void Main()
{
int num=2018, i;
if((num%400==0)||(num%4==0 && num%100!=0))
{
Console.WriteLine('is Leap Year');
}else
{
Console.WriteLine('not Leap Year');
}
}
}
Output: not Leap Year
Program for Taking input a year by user to check that is Leap year or not.
using System;
public class Program
{
public static void Main()
{
int num;
Console.WriteLine('Enter an year to check whether is Leap year or not');
num=int.Parse(Console.ReadLine());
if(num%4==0)
{
if(num%100!=0)
{
if(num%400==0)
{
Console.WriteLine(num+' is a Leap year');
}else
Console.WriteLine(num+' is a Leap year');
}else
{
Console.WriteLine(num+' not a leap year');
}
}else
{
Console.WriteLine('not a leap year');
}
}
}
Output:
Enter an year to check whether is Leap year or not
2020
2020 is a Leap year
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Leap Year:
Leap year is a year in which the day is 366 instead of 365 because there are 29 days in February month. We can find all the leap year by using the following C# program.
Program:
Program for Taking input a year by user to check that is Leap year or not.
Output: