TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Check if the Year is a Leap Year or Not in C#
Ujjwal Patel
Jan 15
2015
Code
27.9
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
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