Teaching UGC NET Mock Test Series 2025 (Paper 1 & 2) Programming and Data Structure Programming in C
What does the following function f() in 'C' return?
int f(unsigned int N) {unsigned int counter = 0; while (N > 0) {counter += N & 1;
N = N >> 1;} return counter == 1;}
1
1 if N is odd, otherwise 0
2
1 if N is a power of 2, otherwise 0
3
1 if the binary representation of N is all 1's, otherwise 0
4
1 if the binary representation of N has any 1's, otherwise 0