(Hint: assume it is true with a Boolean variable then use a loop to find a value to show it is false by setting the Boolean variable to false)
C++ CODE PLEASE
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n;
cout<<"Enter integer: ";
cin>>n;
bool flag=0;
// looping to find powers untii it reaches given value
for(int i=0;;i++){
//if it is power of 2 than make flag as true and break
if(pow(2,i)==n){
flag=1;
break;
}
// if it is greater than n stop the loop
if(pow(2,i)>n)
break;
}
if(flag)
cout<<"True";
else
cout<<"False";
}
NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
Please Like and Support me as it helps me a lot
Get Answers For Free
Most questions answered within 1 hours.