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 __________.
Concept:
((num>>= 1)== (num = num >> 1)) : implies a num is shifted one bit right.
\({\rm{Right\;shif\;formula}} = \frac{{{\rm{number}}}}{{{2^{\rm{i}}}}}\)
Here i means how many bits to shift right
Explanation:
Loop 1 
Func(435) num = 435, count = 0 while(435) condition true 
count = 1 num = 217 
Loop 2 
while217) condition true 
count = 2, num = 108 
Loop 3 
while(108) condition true 
Count = 3 num = 54 
Loop 4 
while(54) condition true 
Count = 4 num = 27 
Loop 5 
while(27) condition true 
Count = 5a num = 13 
Loop 6 
while(13) condition true 
Count = 6 num = 6 
Loop 7 
while(6) condition true 
Count = 7 num = 3 
Loop 8 
while(3) condition true 
Count = 8 num = 1 
Loop 9 
while(1) condition true 
Count = 9 num = 0 
Loop 10 
while (0) condition false Func returns value 9 

Hence 9 is the correct answer.