The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 305 Weeks Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
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.
Â
VERY IMPORTANT: the program must return 0 on success and -1 on failure.
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly