Write a C Program to shift bits. You will take input from the command-line argument (i.e argv[1]. Input should be 8 bits long in binary (i.e XXXXXXXXXX). Shifting means exactly that, shift all the...


Write a C Program to shift bits. You will take input from the command-line argument (i.e argv[1]. Input should be 8 bits long in binary (i.e 01010011).


Shifting means exactly that, shift all the bits in the first operand either left or right the number of time indicated in the second. The second operand should be an integer value. If it is not, then truncate it (pretend the fractional part does not exist). If a shift left would push a bit off of the 'front', it is lost and causes an overflow. Report the overflow and print the bits left over after the shift. If a shift right would push a bit off of the 'back', it is lost and causes an underflow. Report the underflow and print the bits left over after the shift.
e.g.
(shift 2 to the left 1 time .. in essence multiply by 2)
$ ./compu "000101000010"
$ OKAY 1000


(shift 2 to the left 1.5 times .. not an int)
$ ./compu "000101000011"
$ NINT 1000



Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here