Check out example codes for "Check if a Number is Odd or Even using Bitwise Operators". It will help you in understanding the concepts better.

Code Example 1

// C++ program to check for even or odd 
// using Bitwise AND operator 
  
#include <iostream>  
using namespace std;  
    
// Returns true if n is even, else odd  
bool isEven(int n)  
{  
    // n&1 is 1, then odd, else even  
    return (!(n & 1));  
}  
    
// Driver code  
int main()  
{  
    int n = 101;  
    isEven(n)  
? cout << "Even" 
: cout << "Odd";  
    return 0;  
} 

Code Example 2

// C++ program to check for even or odd 
// using Bitwise XOR operator 
  
#include <iostream> 
using namespace std; 
  
// Returns true if n is even, else odd 
bool isEven(int n) 
{ 
  
    // n^1 is n+1, then even, else odd 
    if (n ^ 1 == n + 1) 
        return true; 
    else
        return false; 
} 
  
// Driver code 
int main() 
{ 
    int n = 100; 
    isEven(n)  
? cout << "Even" 
: cout << "Odd"; 
  
    return 0; 
}

Learn ReactJs, React Native from akashmittal.com