Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!
Interview Questions and Answers :: Broadcom Ltd

2. How to check a number, whether it is power of 2 or not.

Answer:

#include

int main()
{
int x;
scanf("%d",&x);
if((x)&&!(x&(x-1)))
{
printf(" %d is power of 2\n",x);
}
else
{
printf(" %d not power of 2 \n",x);
}
}

Post Your Answer Here:      Public      Private

Rate This: +0 -0
Report     

Post Your Reply Here:     

Report Error

Report Error

Please Login First Click Here