2 of 5 edited tags

Count the number of ones in unsigned 16 bit integer

Write some statement(s) which will count the number of ones in a sixteen bit integer when represented as binary.

For example, if a variable s = 1337, then set ones to 6 because 1337 as a sixteen bit binary number is 000010100111001, which contains six ones.