C-Program to check whether a number is power of 2 or not
#include <stdio.h>
#include <string.h>
main()
{
int number;
printf("Enter the number\n");
scanf("%d",&number);
if(!(number&(number-1)))
printf("%d is a power of 2\n",number);
else
printf("%d is not a power of 2\n",number);
}
Comments
Post a Comment