We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Monday, June 6, 2016

Write a Program to Check Whether the Entered Year is a Leap Year or Not in C#

using System;
using static System.Console;


namespace CSarpExamples
{
    class LeapYear
    {
        static int year;
        static void Main()
        {
            WriteLine("Enter the year");
            year = Convert.ToInt32(ReadLine());
            LeapYear ly = new LeapYear();
            ly.LeapYearData();
            ReadLine();
        }

        public void LeapYearData()
        {
            if ((year % 4 == 0 && year % 100 == 0) || (year % 400 == 0))
            {
                WriteLine();
                WriteLine("{0}: is leap year", year);

            }
            else
            {
                WriteLine();
                WriteLine("{0}: is not leap year", year);
            }

        }
    }


}

Output


No comments: