logo CodeStepByStep logo

reverse_bits

Author: Julie Zelenski (on 2018/02/03)

Write a function named reverse_bits that reverses the order of the bits in a 1-byte value of type unsigned char. A common programming question in job interviews is, "reverse the letters (or words) in a string." But for a systems programming interview, you might get the question, "reverse the bits in a byte." For example, the call of reverse_bits(187) should return 221. Your solution does not have to be in-place, and can use variables to hold temporary variables.

Function: Write a C function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.