Friday, March 4, 2011

WAP to Count no. of zeros before 1 has arrived in a Number

#include

int main ()
{
int ch=12;
int i;
int count=0;

for(i=32;i>=0;i--)
{
if((ch & 1)==0)
{
count++;
ch=ch>>1;
}
else
break;
}
printf("%d\n",count);
return 0;
}

No comments :