Interview Questions

What will the following piece of code do int f(unsigned int x ...

C Interview Questions and Answers


(Continued from previous question...)

What will the following piece of code do int f(unsigned int x ...

What will the following piece of code do
int f(unsigned int x)
{
int i;
for (i=0; x!0; x>>=1){
if (x & 0X1)
i++;
}
return i;
}



Answer: returns the number of ones in the input parameter X

(Continued on next question...)

Other Interview Questions