Question DSA-BIT-0046
MediumWhich expression checks whether n > 0 is a power of 2?
- A.
n | 1 == n
- B.
n ^ 1 == 0
- 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 checks whether n > 0 is a power of 2?
n | 1 == n
n ^ 1 == 0
Sign up free to see the answer and a step-by-step explanation.
n % 2 == 0
n & (n − 1) == 0