
6.14 Exercises,Problems,and Projects 367
EXERCISES,PROBLEMS, AND PROJECTS
number, that is, the number contains only 0s and 1s. If that is not the
case, your program should print a message that the number is not a
valid binary number. Then, your program should count how many 1s
are in that word and output the count.
55. Perform the same operations as Question 54, with the following modi-
fication: If the word does not represent a valid binary number, the
program should keep prompting the user for a new word until a word
representing a valid binary number is input by the user.
56. Write a program that inputs a word representing a binary number (0s
and 1s). ...