Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function named bitCount() in bitcount.c that returns the number of 1-bits in the binary representation of its unsigned integer argument. For example, -->59
Write a function named bitCount() in bitcount.c that returns the number of 1-bits in the binary representation of its unsigned integer argument. For example, -->59 = 0b011 1011.<-- --> The number of 1-bits of 59 is 5.<--
#includeint 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 1 ", 1, bitCount (1)); printf ("# 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 */ }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started