Which of the following bitwise operators __ gives 1 if either of the bits is 1 and 0 when both of the bits are 1.ORANDXORNOT
Question
Which of the following bitwise operators __ gives 1 if either of the bits is 1 and 0 when both of the bits are 1.ORANDXORNOT
Solution
The bitwise operator that gives 1 if either of the bits is 1 and 0 when both of the bits are 1 is XOR.
Here's a step by step explanation:
-
Bitwise OR (|): This operator gives 1 if either of the bits is 1, and also gives 1 when both of the bits are 1. So, this is not the correct operator.
-
Bitwise AND (&): This operator gives 1 only when both of the bits are 1. If either of the bits is 0, it gives 0. So, this is not the correct operator.
-
Bitwise XOR (^): This operator gives 1 if either of the bits is 1, but gives 0 when both of the bits are 1. So, this is the correct operator.
-
Bitwise NOT (~): This operator inverts all the bits, turning 0s into 1s and 1s into 0s. So, this is not the correct operator.
Similar Questions
Choose the correct answerWhich of the following statements is true about Bitwise OR operator?OptionsShifts the bits of the number to the right and fills 0 on voids left as a resultReturns 1 if either of the bit is 1 else 0Returns 0 if either of the bit is 0 else 1Returns 1 if both the bits are 1 else 0.
Which bitwise operator is used to check if a bit is set to 1?&|~^
Bitwise operators
Which of the following is not a bitwise operator in C?
Which bitwise operator is used to set a particular bit to 1 in a variable?
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.