Write a program to find whether a number is power of 2?
- prashant raj
- Mar 18, 2022
- 1 min read

#include <iostream>
using namespace std;
int main()
{
int a = 128;
int b = a-1;
if(a && !(a & b))
{
cout<<"Number is power of 2"<<endl;
}
else {
cout<<"Number is not power of 2"<<endl;
}
}
Comentários