Skip to content
Related Articles

Related Articles

Improve Article
Algorithms Quiz | SP2 Contest 1 | Question 14
  • Last Updated : 28 Aug, 2018

Which of the following expression is correct to check if a given number N is a power of 2 or not?
(A) N && (N – 1)
(B) N || (N – 1)
(C) N ^ (N – 1)
(D) N & (N – 1)


Answer: (D)

Explanation: If N & (N – 1) gives 0, then the given number is a power of 2 otherwise not.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :