/** * Print the number of bits set to 1 in the binary * representation of N (N<32). * Input: 3 * Output: 2 */ #include int main() { int n; int nrBits = 0; do { scanf("%d", &n); } while (n >= 31); while(n){ nrBits += n%2; n /= 2; //printf("n = %d, nrBitds = %d\n",n,nrBits); } printf("%d\n",nrBits); return 0; }