Extract Bit Field from 16-bit Register

Code

#include <stdio.h>

int countSetBits(unsigned int n) {
    // Write your code here
}

int main() {
    int n;
    scanf("%d", &n);
    printf("%d", countSetBits(n));
    return 0;
}

Solving Approach

 

 

 

Upvote
Downvote
Loading...

Input

0x01F0

Expected Output

31