C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Check if the Year is a Leap Year or Not in C#
WhatsApp
Ujjwal Patel
Jan 15
2015
28.3
k
0
1
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
namespace
ConsoleApplication1
{
class
CalcAvgPerc
{
static
void
Main(
string
[] args)
{
int
year;
Console.WriteLine(
"Enter the year you want to check is Leap or not"
);
year =
int
.Parse(Console.ReadLine());
Console.WriteLine(
"Checking....."
);
System.Threading.Thread.Sleep(2000);
if
(year % 400 == 0)
Console.WriteLine(
"Year {0} is Leap"
, year);
else
if
(year % 100 == 0)
Console.WriteLine(
"Year {0} is not a Leap Year"
, year);
else
if
(year % 4 == 0)
Console.WriteLine(
"Year {0} is a Leap Year"
, year);
else
Console.WriteLine(
"Year {0} is not a Leap Year"
, year);
Console.ReadKey();
}
}
}
C#
Leap Year
Up Next
Check if the Year is a Leap Year or Not in C#