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;
}
Post A Comment:
0 comments: