Thursday, March 25, 2010

How can we display the bits of a integer without using array, string and even a single variable

Here is the answer....

int main()
{
int i = 123;
while(i!=0)
{
if (i & (1<<31))
printf("1");
else
printf("0");
i <<= 1;
}
}

No comments: