#include
int main()
{
int num = 0;int k = 0;
printf("enter a number");
scanf("%d",&num);
printf("\nIsPoweroftwo = %d\n",isPowerOfTwo(num));
while(1) {
printf("\nDo you want to continue? 1 or 0\n");
scanf("%d",&k);
if(k){
printf("enter a number");
scanf("%d",&num);
printf("\nIsPoweroftwo = %d\n",isPowerOfTwo(num));
} else {
break;
}
}
}
int isPowerOfTwo (unsigned int x)
{
return ((x > 0) && ((x & (~x + 1)) == x));
}
int main()
{
int num = 0;int k = 0;
printf("enter a number");
scanf("%d",&num);
printf("\nIsPoweroftwo = %d\n",isPowerOfTwo(num));
while(1) {
printf("\nDo you want to continue? 1 or 0\n");
scanf("%d",&k);
if(k){
printf("enter a number");
scanf("%d",&num);
printf("\nIsPoweroftwo = %d\n",isPowerOfTwo(num));
} else {
break;
}
}
}
int isPowerOfTwo (unsigned int x)
{
return ((x > 0) && ((x & (~x + 1)) == x));
}