Tuesday, 3 March 2015

//C# Program to Check Whether the Entered Year is a Leap Year or Not
using System;
class myclass
{
    public static void Main()
    {
        int y;
        Console.WriteLine("Enter the Year in Four Digits : ");
        y = Convert.ToInt32(Console.ReadLine());
        leapyear obj = new leapyear();
        obj.leap(y);
       Console.Read();
    }
}
class leapyear
{
    public void leap(int y)
    {
        if ((y % 4 == 0))
        {
            Console.WriteLine("{0} is a Leap Year", y);
        }
        else
        {
            Console.WriteLine("{0} is not a Leap Year", y);
        }
   }
}

No comments:

Post a Comment