Question DSA-BIT-0012
MediumHow do you set the k-th bit (0-indexed) of n?
- A.
n & (1 << k)
- B.
n ^ k
- C.
n >> k
- D.
n | (1 << k)
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
How do you set the k-th bit (0-indexed) of n?
n & (1 << k)
n ^ k
n >> k
n | (1 << k)
Sign up free to see the answer and a step-by-step explanation.