Skip to content
Related Articles

Related Articles

Improve Article

C | Operators | Question 26

  • Difficulty Level : Basic
  • Last Updated : 28 Jun, 2021

What does the following statement do?




x  = x | 1 << n;

(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


Answer: (B)

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

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :