C++ Program to check if a Number is Even or Odd

C++ Program to check if a Number is Even or Odd

How can we check even or odd number in C++? Here we are using modulus operator to check and "cout" to print the result.

Even or odd in C++ :



#include <iostream>
using namespace std;

int main() 
{
    int number;
    cout << "Please Enter any Integer Value : ";
    cin >> number;

    if(number % 2 == 0)
        cout << number <<" is an Even Number";
    else
        cout << number <<" is an Odd Number";

    return 0;
}
  

Output :