So no matter how many number of 0's is present before it?

The Gateway to Computer Science Excellence

0 votes

Consider the C function func shown below:

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

The value returned by func(0235) is ________

+5 votes

Best answer

0 votes

8

Binary of 235:11101011

Now doing right shift and incrmenting by 1, means essentially counting the number of bits in the binary version of 235, which is 8.

So ans is 8

Binary of 235:11101011

Now doing right shift and incrmenting by 1, means essentially counting the number of bits in the binary version of 235, which is 8.

So ans is 8

52,375 questions

60,572 answers

201,978 comments

95,388 users