& operator can be used to quickly check if a number is odd or even

PHOTO EMBED

Thu Mar 24 2022 11:59:19 GMT+0000 (Coordinated Universal Time)

Saved by @atkumarvishnu #c++

#include <iostream>
using namespace std;
  
int main() {
  
    int x = 19 ;
    (x & 1) ? cout<<"Odd" : cout<< "Even" ;
        
    return 0;
}
content_copyCOPY

The value of expression (x & 1) would be non-zero only if x is odd, otherwise the value would be zero.

https://www.geeksforgeeks.org/bitwise-operators-in-c-cpp/