Saturday, 25 February 2017

Consider the function func shown below:


int func(int num)
{
    int count = 0;
    while (num)
    {
        count++;
        num >>= 1;
    }
    return (count);
}

The value returned by func(435)is __________.
Answer: 9
Explanation: The function mainly returns position of Most significant bit in binary representation of n. The MSD in binary representation of 435 is 9th bit.

No comments:

Post a Comment