Question #3


The parity of a character is a measure of the number of bits that are set (i.e., equal 1) in its internal representation. We'll say that if a character has an even number of 1 bits it has even parity, otherwise it has odd parity. In 8 bit ASCII code, for example, capital A = 65 which is 01000001. Since there are two 1 bits, its parity is even.

For a string of one or more characters, the total parity of the string is calculated from the total 1's in the representations of all characters.

Write a program which reads lines of text and determines the the total parity for each line. The end of line characters are ignored.