Q:

Write C# Program to check leap year using conditional operator

0

Write C# Program to check leap year using conditional operator.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..

using System;
 
namespace csharpprograms
{
    class Program
    {
        static void Main(string[] args)
        {
           int year;
           Console.WriteLine("Enter Year");
           year = Convert.ToInt32(Console.ReadLine());
           Console.WriteLine( year % 4 == 0 ? "Entered year is a leap" : "Not leap year");
           Console.ReadLine();        
 
           Console.ReadLine();
 
        }
    }
}

Result:

Enter Year

2018

Not leap year

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write C# Program to Check whether an alphabet is a... >>
<< Write C# Program to find the Largest among Three V...