Friday 8 February 2013

6

Write a one line code to check if a number is a power of 2.
Example : 8 = 2^3 so 8 is a power of 2 , 9 is not a power of 2.
Hint : you need to know about Bitwise Operators.

What will be output of following c code?

#include<stdio.h>
int main()
{
int i=2,j=2;
while(i+1?--i:j++)
printf("%d",i);
return 0;
}
Join me on Facebook