Program to check number is whether EVEN or ODD without using any arithmetic or relational operators.

Опубликовано: 14 Октябрь 2024
на канале: Priyanka Jamdar
953
8

We can check whether an integer number is EVEN or ODD without using any Arithmetic or Relational operators.
Here is a simple trick that we can use to check whether number is EVEN or ODD. Using Logical AND (&) operator we can check it, each EVEN number has 0th bit LOW (0) and ODD number has 0th bit HIGH (1).

The statement (number & 0x01) will check that 0th bit is HIGH, if it is HIGH (1) number will be an ODD otherwise number will be an EVEN.

GitHub Link:-
https://github.com/priyanka2907/C-/bl...