Question
Write a function, void lo2b(unsigned short) in lo2b.c, that takes an integer of type unsigned short as argument and inspects its bits by using the
Write a function, void lo2b(unsigned short) in lo2b.c, that takes an integer of type unsigned short as argument and inspects its bits by using the shift operator >> discussed in class. lo2b() inspects the two least significant bits of the input by performing an & with a suitable mask that blocks out/ignores all other bits. It outputs the 2-bit value using printf() in decimal format. Write a function, void hi2b(unsigned short) in hi2b.c, that does the same for the two most significant bits of the input. Write a function, void allb(unsigned int) in allb.c, that outputs all the bits of the input on a single line (no space between bits). Print the least significant bit first, followed by the second least significant bit, and so forth. Check that the functions work correctly by calling them from main(). The TAs will use their own main() to test your code.
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