You are here: Home / Topics / C# program to check whether the given number N is even or odd

C# program to check whether the given number N is even or odd

Filed under: C# on 2023-09-21 06:52:53

Here you will find an algorithm and program in C# programming language to check whether the given number is even or odd number. First let us understand what is even number and odd number.

Explanation : If the number is divisible by 2 then the number is even number and if the number is not divisible by 2 then the number is odd number.

For Example : 4 is Even number as it is divisible by 2 and 5 is odd number as it is not divisible by 2.

Even Odd Algorithm
START
Step 1: [ Take Input ] Read: Number N
Step 2: Check: If N%2 == 0 Then
Print : N is an Even Number.
Else
Print : N is an Odd Number.
STOP


C# Program to Check Whether a Number is Even or Odd


using System;
class LFC
{
static void Main(string[] args)
{
 int N=10;
 if (N % 2 == 0)
 {
  Console.Write("The number "+N+" is Even number");
  Console.Read();
 }
 else
 {
  Console.Write("The number "+N+" is Even number");
  Console.Read();
 }
}
}
Output
The number 10 is Even number

About Author:
G
Geetam     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.