P7 To find whether the given year is leap or not

    class Program
    {
        static void Main(string[] args)
        {
            int n;
            Console.Write("Enter the number : ");
            n = int.Parse(Console.ReadLine());
            if ((n % 4 == 0) && ((n % 100 == 0) || (n % 400 != 0)))
            {
                Console.WriteLine(n + " is a leap year");
            }
            else
            {
                Console.WriteLine(n + " is not a leap year");
            }
            Console.ReadLine();
        }
    }

Output 1 :










Output 2 :

No comments:

Post a Comment