hamburger

Which Bitwise Operator is Suitable for Turning on a Particular Bit in a Number?

By BYJU'S Exam Prep

Updated on: September 25th, 2023

Which bitwise operator is suitable for turning on a particular bit in a number?

  1. && operator
  2. & operator
  3. || operator
  4. | operator

Answer: D. | operator

The | bitwise operator is suitable for turning on the bit in a number.

Solution

OR (|) bitwise operator is suitable for turning on a particular bit in a number. To arrive at the solution, we can clearly eliminate options A and C as they represent logical AND and logical OR operations, respectively. Now option B is bitwise AND (&), it cannot be used to turn on a particular bit in a number because if the input bit is 0, the bitwise AND will return 0 as the output. On the other hand, if bitwise OR is used, even if the input bit is set to 0, it will activate the output.

☛ Related Questions:

Our Apps Playstore
POPULAR EXAMS
SSC and Bank
Other Exams
GradeStack Learning Pvt. Ltd.Windsor IT Park, Tower - A, 2nd Floor, Sector 125, Noida, Uttar Pradesh 201303 help@byjusexamprep.com
Home Practice Test Series Premium