C | Operators | Question 26
What does the following statement do?
(A) Sets x as 2n
(B) Sets (n+1)th bit of x
(C) Toggles (n+1)th bit of x
(D) Unsets (n+1)th bit of x
Explanation: Let n be 3, the value of expression 1 << n would be 8 (In binary 00001000).
If we do bitwise or of binary 00001000 with any number x would set its (n+1)th bit from left side.
Quiz of this Question