const int bit_count = 31; int number; cin >> number; int i; for(i = 0; i < bit_count; i++) { code example
Example: bit counting
countBits = (n) => n.toString(2).split("0").join("").length;
countBits = (n) => n.toString(2).split("0").join("").length;