C++ Program to check number is even or odd


In this Example, You will learn How to check a number is even or odd in C++.


12 % 2 == 0

14 % 2 == 0


Example: Check Number is Even or Odd in C++

Run it Now
#include<iostream>
using namespace std;

int main() {

  int n;
  cout << "Enter a Number :";
  cin>>n;

  if (n % 2 == 0) {
      cout << "\nNumber is Even :" << n;
  } else {
      cout << "\nNumber is Odd :" << n;
  }

  return 0;
}

Output:

Enter a Number :14
Number is Even :14