Home » C++ Programming » Data Types » Question
  1. Which of these expressions will return true if the input integer a is a power of two?
    1. (~a & (a – 1)) == 0;
    2. (a | (a – 1)) == 0;
    3. (a & (a – 1)) == 0;
    4. (a | (a + 1)) == 0;
    5. None of these
Correct Option: C

Power of two integers have a single set bit followed by unset bits.



Your comments will be displayed only after manual approval.