Question DSA-BIT-0028
EasyWhich expression toggles (flips) bit k of n (bits counted from 0)?
- A.
n ^ (1 << k)
- B.
n >> k
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Bit Manipulation question
Which expression toggles (flips) bit k of n (bits counted from 0)?
n ^ (1 << k)
n >> k
Sign up free to see the answer and a step-by-step explanation.
n | (1 << k)
n & (1 << k)