Friday, August 19, 2016

Check Leap Year C#-Example

Program to Check Leap Year


This C# Program Checks Whether the Entered Year is a Leap Year or Not.

When A year is divided by 4, If remainder is 0 then the year is called a leap year.

Below is a C# Program to Check Whether the Entered Year is a Leap Year or Not.




using System;

namespace Zappmania.Example.IsLeapYear


public class LeapYearDemo

public static void Main(string[] args)

var year = 0;
var obj = new LeapYearDemo();
obj.ReadInputData(out year);
if (obj.IsLeapYear(year))

Console.WriteLine("0 is a Leap Year", year);

else

Console.WriteLine("0 is not a Leap Year", year);

Console.ReadLine();


public void ReadInputData(out int year)

Console.WriteLine("Enter the Year in Four Digits : ");
year = Convert.ToInt32(Console.ReadLine());

public bool IsLeapYear(int year)

if ((year % 4 == 0 && year % 100 != 0)




Check Leap Year C#-Example

No comments:

Post a Comment