Even Number Odd Number Example Program in C++ Programming

Here we have the C++ 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 cpp programming language. It is denoted by using % ( percentage ) symbol.

C++ Program to Check for Even or Odd Number

 1 #include <iostream>
 2 
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     int num,rem;
 8     cout << "Enter an Integer Number"<<endl;
 9     cin >> num;
10 
11     rem = num % 2;
12 
13     if( rem == 0 )
14         cout << num << " is an Even Number";
15     else
16         cout << num << " is an Odd Number";
17 
18     return 0;
19 }

For Explanation Checkout this Video