When even numbers are divided by 2, the output will be 0, modulus of odd numbers with 2 gives the output value of 1.
C++ Program to find even and odd numbers using if-else condition
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter an integer: ";
cin >> n;
if ( n%2 == 0)
cout << n << " is even.";
}
else {
cout << n << " is odd.";
}
return 0;
}
