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

Requirements

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

Hint

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.

Demo

using System;
class Program/*  w  w w . j a  va2 s.  co 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");
        }
        else
        {
            Console.WriteLine("The number is odd");
        }
    }
}

Result