Consider the function fun1 shown below: int fun1 (int num) { int count = 0; while (num) { count ++; num ≫= 1; } return (count); } The value returned by fun1 (435) is
Consider the function fun1 shown below: int fun1 (int num) { int count = 0; while (num) { count ++; num ≫= 1; } return (count); } The value returned by fun1 (435) is Correct Answer 9
(435)10 = (110110011)2
The binary equivalent of 435 has 9 bits.
In while loop, num ≫= 1 performs 1-bit shift operation in each iteration.
As there are 9 bits, total number of iterations = 9
The value returned by fun1 (435) is 9.
মোঃ আরিফুল ইসলাম
Feb 20, 2025