Advertisement

Latest Post

Sunday, 1 January 2017

How to Find A Number is Even or Odd [C#]

Write a program in C# that finds whether a given number is even or odd.

Following is the simple C# code :

class Lab
    {
        static void Main(string[] args)
        {

            int number;
            Console.Write("Enter a Number : ");
            number = Convert.ToInt32(Console.ReadLine());
            if (number % 2 == 0)
            {
                Console.Write("Entered Number is an Even Number");
                Console.Read();
            }
            else
            {
                Console.Write("Entered Number is an Odd Number");
                Console.Read();
            }

        }
    }

Output:-

Government Jobs