Consider the following C++ function f(): unsigned int f(unsigned int n) {…
PYQ UGC NET 2019
Consider the following C++ function f():
unsigned int f(unsigned int n) {
unsigned int b=0;
while (n) {
b+=n & 1;
n>>1;
}
return b;
}
The function f() returns the int that represents the ____P____ in the binary representation of positive integer n, where P is
- A.
number of 0’s
- B.
number of bits
- C.
number of consecutive 1’s
- D.
number of 1’s
Attempted by 16 students.
Sign up free to check your answer
Sign up freeLoading lesson…

