C# Program to Find a Year Leap or not & Find odd or Even Number

Posted by Libin Antony on 13/01/2023 

Just sharing the C# Programs and O/P s for your reference. Kindly discuss, if any contradictions.

C# Program to Find a Year Leap or not :

Program:

 using System;

namespace Leapyearornot

{

    class Leapyear

    {

        static void Main(string[] args)

        {

            Console.WriteLine("Enter Year:");

            int year = Convert.ToInt32(Console.ReadLine());

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

            {

                Console.WriteLine(year + "is a leap year");

            }

            else

            {

                Console.WriteLine(year + "is not a leap year");

            }

        }

    }


OUTPUT:



C# Program to Find a Number odd or Even Number:

Program:

using System;

namespace oddoreven

{

    class oddeven

    {

        static void Main(string[] args)

 

        {

            Console.WriteLine("Enter Number:");

            int num = Convert.ToInt32(Console.ReadLine());

            if ((num % 2 == 0))

            {

                Console.WriteLine(num + "is a even number");

            }

            else

            {

                Console.WriteLine(num + "is not a even number");

            }

        }

    }

}

OUTPUT:









Comments

Popular posts from this blog

General C# Programs for Beginners

C# Program for Coin Vending Machine

How to make a vertical text box in Microsoft visio?