Skip to content
Related Articles

Related Articles

C | Operators | Question 26

View Discussion
Improve Article
Save Article
  • 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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!