C++ Program to Find Even or Odd Number

Here’s a simple C++ program to check whether a number is even or odd:

#include <iostream>
using namespace std;

int main() {
    int num;
    cout << "Enter an integer: ";
    cin >> num;

    if (num % 2 == 0)
        cout << num << " is even." << endl;
    else
        cout << num << " is odd." << endl;

    return 0;
}

Output

For example:

  • If the user enters 4, the output will be 4 is even.
  • If the user enters 7, the output will be 7 is odd.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top