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 be4 is even.
- If the user enters
7
, the output will be7 is odd.