C++ Program To Check Whether Number is Even Or Odd

C++// C++ program to check // for even or odd #include <iostream> using namespace std; // Returns true if n is // even, else odd bool isEven(int n) { return (n % 2 == 0); } // Driver code int main() { int n = 247; if (isEven(n) == true) { cout << "Even" << endl; } else { cout << "Odd"; } return 0; }

Output

Odd

Comments

Leave a Reply

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