How do you see if a variable is power of 2

Without changing the variable

#include <iostream>
using namespace std ;

int main(){
int a=8;

while(a>2) {
a=a/2;
}
cout<<a << endl;
return 0;

}
Last edited on
Use a temporary variable 'b' to perform calculations on .
Last edited on
Topic archived. No new replies allowed.