Question: Write a function named bitcount () in bitcount.c that returns the number of 1-bits in the binary representation of its unsigned integer argument. Remember to

 Write a function named bitcount () in bitcount.c that returns the

Write a function named bitcount () in bitcount.c that returns the number of 1-bits in the binary representation of its unsigned integer argument. Remember to fill in the identification information and run the completed program to verify correctness./* Name: Lab section time: */#include int bitCount (unsigned int n); int main () {printf ("# 1-bits in base 2 representation of %u = %d, should be 0 ", 0, bitCount (0)); printf ("# 1-bits in base 2 representation of %u = %d, should be l ", 1, bitCount (1)); prin f ("# 1-bits in base 2 representation of %u = %d, should be 16 ", 2863311530u, bitCount (2863311530u)); printf ("# 1-bits in base 2 representation of %u = %d, should be 1 ", 536870912, bitcount (536870912)); printf ("# 1-bits in base 2 representation of %u = %d, should be 32 ", 4294967295u, bitCount (4294967295u)); return 0;} int bitCount (unsigned int n) {/* your code here */} You have decided that you want your bitcount program above to work from the command-line (see K&R Sec. 5.10), as follows: # ./bitcount 17 2 # ./bitcount 255 8 # ./bitcount 10 20 too many arguments! # ./bitcount [the same result as from problem 4] You may assume that the single argument will always be an integer in the range from 0 to 2^31-1. You will find the function atoi helpful

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!