C program to simulate a binary register that supports shift


C++ program to simulate a binary register that supports shift right and shift left operations. The original value stored in the register, its size and what operation(s) to perform and how many times are all given via the command line arguments. The program must use a class to simulate that register and it should use the stl vector to hold the value of the bits in the register. the program must execute in Linux and g++ compiler.

ARGUMENTS MUST BE SUPPORTED IN ANY ORDER.

by default register must inject 0 values unless told otherwise via command line arguments.

Here are some of the parameters to support as command line arguments:

-i "010101": Initial values stored in register.

-s 6: Specifies the number of bits in shift register.

-r 2: shift the register right by two positions.

-l 3: shift left register by 3 positions.

-v 1: value to inject in vacated bits if other than default.

-p: prints the value of bits in register after performing all the operations. Bits must be printed as a non-spaced string of 0 or 1s and terminated by a new line.

Multiple operations may be specified and they must be performed in the order specified in the command line argument list.

Solution Preview :

Prepared by a verified Expert
Business Economics: C program to simulate a binary register that supports shift
Reference No:- TGS02461441

Now Priced at $20 (50% Discount)

Recommended (99%)

Rated (4.3/5)