Computer Science · C Programming
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; }
- 11 if N is odd, otherwise 0
- 21 if N is a power of 2, otherwise 0✓
- 31 if the binary representation of N is all 1's, otherwise 0
- 41 if the binary representation of N has any 1's, otherwise 0
Correct answer
1 if N is a power of 2, otherwise 0
Download Single Question PDF
Save this question and verified answer as a clean study sheet with live clickable link.
Share with Friends & Study Groups
Challenge your peer aspirants on WhatsApp or Telegram to solve this question!
Preparing for Computer Science?
Practice full-length mock tests with real exam timers, instant score analysis, and all-India ranking.
Want more practice questions on C Programming?
Solve complete topic-wise tests with detailed solutions on GkGet.
Related Practice Questions
Recommended practice questions in Computer Science · C Programming