Even or Odd number program in C#

A simple even-odd number program in C#. If number is completely divisible by 2 and remainder remain 0, then it is even number. If remainder not remain 0 then it is odd number.

Example of even number:

2, 4, 6, 8, 10, 12, etc..

Example of odd number:

1, 3, 5, 7, 8, 9, 11, etc.

Program of even or odd number in console application


    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace even_odd
    {
        class Program
        {
            static void Main(string[] args)
            {
                int q;
                Console.WriteLine("ENTER ANY NUMBER :- ");
                q = Convert.ToInt32(Console.ReadLine());
                if (q % 2 == 0)
                {
                    Console.WriteLine("ENTER NUMBER IS EVEN.");
                }
                else
                {
                    Console.WriteLine("ENTER NUMBER IS ODD.");
                }
                Console.ReadLine();
            }
        }
    }
		

Output

	
   ENTER ANY NUMBER :- 5
   ENTER NUMBER IS ODD.
           

Post Your Comment