Even or Odd Number Example Program in C# Programming Language

Here we have the C# aka C Sharp Programming Language Example Program to Check for Even or Odd Number.

When you divide a number by 2 if you get the remainder as 0 then that number is said to be Even Number. If the remainder is a Non Zero value then it is an Odd Number.

Here we are using the modulus operator available in C# programming language. It is denoted by using % ( percentage ) symbol.

C# Program to Check for Even or Odd Number

 1 using System;
 2 
 3 namespace odd_even
 4 {
 5     class Program
 6     {
 7         static void Main(string[] args)
 8         {
 9             int number, remainder;
10             Console.WriteLine("Pls Enter an Integer Value");
11             number = Convert.ToInt32(Console.ReadLine());
12 
13             remainder = number % 2;
14 
15             if (remainder == 0)
16                 Console.WriteLine("{0} is an Even Number",number);
17             else
18                 Console.WriteLine("{0} is an Odd Number",number);
19 
20             Console.WriteLine("Press any key to exit");
21             Console.ReadKey();
22         }
23     }
24 }

For Explanation Checkout this Video