- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# C# Program to find whether the Number is Divisible by 2

If the remainder of the number when it is divided by 2 is 0, then it would be divisible by 2.

Let’s say our number is 5, we will check it using the following if-else −

// checking if the number is divisible by 2 or not if (num % 2 == 0) { Console.WriteLine("Divisible by 2 "); } else { Console.WriteLine("Not divisible by 2"); }

## Example

The following is an example to find whether the number is divisible by 2 or not.

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class MyApplication { static void Main(string[] args) { int num; num = 5; // checking if the number is divisible by 2 or not if (num % 2 == 0) { Console.WriteLine("Divisible by 2 "); } else { Console.WriteLine("Not divisible by 2"); } Console.ReadLine(); } } }

## Output

Not divisible by 2

- Related Questions & Answers
- How to find whether the Number is Divisible by 2 using C#?
- Write a C# program to check if a number is divisible by 2
- Find the Numbers that are not divisible by any number in the range [2, 10] using C++
- Program to find number of consecutive subsequences whose sum is divisible by k in Python
- Find N digits number which is divisible by D in C++
- Find the first natural number whose factorial is divisible by x in C++
- C/C++ Program to check whether it is possible to make the divisible by 3 number using all digits in an array?
- C++ Program to find whether a number is the power of two?
- Find the number closest to n and divisible by m in C++
- Find if a number is divisible by every number in a list in C++
- Python Program to check whether it is possible to make a divisible by 3 number using all digits in an array
- Java Program to check whether it is possible to make a divisible by 3 number using all digits in an array
- Java program to find whether given number is even or odd
- Check if a large number is divisible by 2, 3 and 5 or not in C++
- C++ Program for the Largest K digit number divisible by X?

Advertisements