## Q. Write a program to check whether the given number N is even or odd.

The article will help you write a program to check whether a number is an even number or an odd number. So a number is called an even number if it is perfectly divisible by two or in other words when we divide a number by two and at that point if we get the reminder as zero then it means that the number is even number and if we get any another value as a reminder, it means that the number is odd number.

**Even Number **:- Even numbers are the numbers which are divisible by 2. For Example :- 2, 4, 6, 8...

**Odd Number **:- Odd numbers are the number which are not divisible by 2. For Example :- 1, 3, 5, 7...

**For Example :-** We are going to have the number N = 10, so to check whether the number is even or odd number, we can use the modulus operator to get the remainder and when you divide the entered number(N=10) by 2 we will get reminder(rem) and then we going compare the value of that reminder (rem) whether it is zero or not and based on that comparison we are going to find out whether this number is even or odd number.

**input **: N = 10

**output **: Even Number

So as we can see that the number N is divisible by 2, so it is a Even Number.

#### Algorithm to check number is even or odd

\\Algorithm to check number is even or odd. 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

#### Program to check whether the number is even or odd

\\C program to check whether the number is even or odd. #include <stdio.h> int main() { int N=10; // True if num is perfectly divisible by 2 if(N % 2 == 0) printf("The number %d is Even number",N); else printf("The number %d is Odd number",N); return 0; }

\\C++ program to check whether the number is even or odd. #include <iostream> using namespace std; int main() { int N=10; if ( N % 2 == 0) cout <<"The number "<< N << " is Even number."; else cout <<"The number "<< N << " is Even number."; return 0; }

\\Java program to check whether the number is even or odd. import java.util.Scanner; class LFC { public static void main(String args[]) { int N=10; /* If number is divisible by 2 then it's an even number * else odd number*/ if ( N % 2 == 0 ) System.out.println("The number "+N+" is Even number"); else System.out.println("The number "+N+" is Odd number"); } }

\\Python program to check whether the number is even or odd. N=10 if (N % 2) == 0: print("The number {0} is Even number".format(N)) else: print("The number {0} is Odd number".format(N))

\\ C# program to check whether the 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(); } } }

\\PHP program to check whether the number is even or odd. $N=10; if($N%2==0) { echo "The number $N is Even number"; } else { echo "The number $N is Odd number"; }

\\C program to check whether the number is even or odd. #include <stdio.h> int main() { int N=10; // True if num is perfectly divisible by 2 if(N % 2 == 0) printf("The number %d is Even number",N); else printf("The number %d is Odd number",N); return 0; }

#### Output

The number 10 is Even number

## Recommended Programs

Program to find factorial of a numberProgram to count number of digits in a number