Skip to main content

To check the number is power if two or not

// To check the number is power if two or not

bool ispowOf2two(int n)
{
 return (n&&!(n&n-1));
}

int main ()
{
 cout<< ispowOf2two(16);
 return 0;
}

Comments

Popular posts from this blog

Array Data Structure

7 features of OOPs

The 7 features of OOPs are as follows: 1. Incapsulation 2. Abstraction 3. Inheritance 4. Polymorphism 5. Object must be used 6. Massage passing : One object can interect with another object 7. Dynamic binding The most initial 4 are the basic OOPs features that is required.