Check whether a given number is even or odd | A simple C ++ program to check for even or odd ; Returns true if n is even , else odd ; n & 1 is 1 , then odd , else even ; Driver code
#include <iostream> NEW_LINE using namespace std ; bool isEven ( int n ) { return ( ! ( n & 1 ) ) ; } int main ( ) { int n = 101 ; isEven ( n ) ? cout << " Even " : cout << " Odd " ; return 0 ; }