Question: Write a program called count_ones.c that contains the following function: int count_ones(unsigned char ch); where count_ones returns the number of bits in the binary representation
Write a program called count_ones.c
that contains the following function:
int count_ones(unsigned char ch); where count_ones returns the number of bits in the binary representation of ch that have a value 1.
You need to implement count_ones yourself and not use any libraries/built-in functions/macros.
Write a main function in count_ones.c that calls count_ones .
The main function continuously asks the user for input until x is entered:
Enter character: r
Number of 1 bits in r is: 4
Enter character: a
Number of 1 bits in a is: 3
Enter character: x
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
