Write a program to find if a number n is the power of two.  

Input-Output Format:
Input consists of one integer.
Refer sample Input Output for output format.
 
Note: n is a non-negative number.

Sample Input and Output 1:
Enter a number
2
Yes
 
Sample Input and Output 2:
Enter a number
5
No 



Program Code:
#include<stdio.h>
int main()
{
int a;
printf("Enter a number\n");
scanf("%d", &a);
if((a & (a-1)) == 0)
{
    printf("Yes");
}
else
{
    printf("No");
}
return 0;

}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: