1 Task: Display a Binary Integer In this lab, we’re going to manipulate binary numbers in a C program. More specifically, we’re going to write a C program that can print out the binary pattern of any 32-bit integer numbers. We have provided a start code for you: where display_32() is the function you need to complete. Here we use int32_t and int8_t as substitutes algorithm would be extracting every bit of the number using bit-wise operations and shifting, while calling display() to print out one bit. An example of output from the code above would be:
Notice two things: You need to output all 32 bits with leading zeros; MSB is the leftmost bit while LSB the rightmost, so you need to print out MSB first, and LSB last.
Requirements Your code must be able to compile successfully and executed without segmentation fault or any other type errors; own tests; 1 You must not use division or multiplication in any part of your code (addition and subtraction are allowed, though); only use shifting ( << and/or >> ) and bit-wise operators ( & and/or | ) to extract individual bits; You can create any functions that can help you, but you must call display() and display_32() functions. Also, you wouldn’t need to include any more header files; All 32 bits must be printed out; MSB is the leftmost bit, while LSB the rightmost.
2 Grading The lab will be graded based on a total of 10 points. the code does not compile, or executes with run-time error; if used multiplication and/or division and/or modulo operators; -5: display() and/or display_32() are not used; -5: included other header files, and/or the starter code was changed (except main() ); -5: no display of binary number and/or the result is incorrect; -3: negative numbers are not displayed correctly; -3: leading zeros are not printed out; -3: the binary number is printed in the reverse order (i.e., MSB is the right-most); -1: no pledge and/or name in C file.
Attendance: check off at the end of the lab to get attendance credit.