This is a C# Program to check whether the entered year is a leap year or not.
Problem Description
This C# Program Checks Whether the Entered Year is a Leap Year or Not.
Problem Solution
When A year is divided by 4. If the remainder becomes 0 then the year is called a leap year.
Program/Source Code
Here is the source code of the C# Program to Check Whether the Entered Year is a Leap Year or Not. The C# program is successfully compiled and executed with Microsoft Visual Studio.
using System;
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Enter Year : ");
int Year = int.Parse(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();
}
}
No comments:
Post a Comment