CSharp - Write program to Check if user input is Odd or Even Numbers


You will write a program that evaluates whether the number entered by the user is odd or even.


The core of the solution is to determine the remainder of dividing the entered number by 2.

If the remainder is zero, the number is even.

If there is some remainder, the number is odd.


using System;
class Program/*from w  ww  . j  av  a2  s  . c o m*/
    static void Main(string[] args)
        // Input 
        Console.Write("Enter a number: ");
        string input = Console.ReadLine();
        int number = Convert.ToInt32(input);

        // Remainder calculation 
        int remainderAfterDivisionByTwo = number % 2;

        // Evaluation 
        if (remainderAfterDivisionByTwo == 0)
            Console.WriteLine("The number is even");
            Console.WriteLine("The number is odd");