By Aalok Kumar
Hello programmers, Using Bit Manipulation, I have written a C++ program to check whether a number is Even or Odd in just one line of code.
Bitwise operators are used to working on Bit-level to manipulate Bits.
In my program, the Bitwise operator & is used to check whether a number is Odd or Even.
When the binary equivalent of a number and 1 is operated with Bitwise & operator, the result is either 0 or 1.
if the result is 0 then it is an Even number, otherwise, it is an Odd number.
Sample output is shown below:
Enter a number: 6 The number 6 is even Enter a number: 5 The number 5 is odd
Submitted by Aalok Kumar (Aaloks766626)
Download packets of source code on Coders Packet