Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The program will ask the user for an integer and accept theuser\'s input. It wil

ID: 3610829 • Letter: T

Question

The program will ask the user for an integer and accept theuser's input. It will then display the entered value in hexadecimal(base 16) and binary (base 2). Running your program maydisplay:

enter an integer: 10563335
hex: 00a12f07
bin: 00000000101000010010111100000111

Doing the conversions The program will do the conversion using shift and bitwiselogical operations. To display an int n in binary you willdisplay one bit at a time in the following manner:
          Shiftthe int enough places right (>>) to move the bit inquestion into bit position 0.
          Use abitmask to clear all but the low order bit.
          Print theresulting int to display the bit. Converting to hex is similar but you must shift theint far enough to the right to move a group of bits intothe four low-order bit positions. Use a bitmask which clears allbut the four low-order bits. The result will be an int inthe range 0 through 15. If the int is less than 10 printit. Otherwise print the appropriate letter (a throughf) for the corresponding hex digit. The program must work properly on systems and compilers withdifferent sized ints. Use the sizeof operator todetermine the correct size of an int. The sample terminal session run program (at least) fourtimes. Have program convert the values -1, 195934910, 65535,and 65536. The program will ask the user for an integer and accept theuser's input. It will then display the entered value in hexadecimal(base 16) and binary (base 2). Running your program maydisplay:

enter an integer: 10563335
hex: 00a12f07
bin: 00000000101000010010111100000111

Doing the conversions The program will do the conversion using shift and bitwiselogical operations. To display an int n in binary you willdisplay one bit at a time in the following manner:
          Shiftthe int enough places right (>>) to move the bit inquestion into bit position 0.
          Use abitmask to clear all but the low order bit.
          Print theresulting int to display the bit. Converting to hex is similar but you must shift theint far enough to the right to move a group of bits intothe four low-order bit positions. Use a bitmask which clears allbut the four low-order bits. The result will be an int inthe range 0 through 15. If the int is less than 10 printit. Otherwise print the appropriate letter (a throughf) for the corresponding hex digit. The program must work properly on systems and compilers withdifferent sized ints. Use the sizeof operator todetermine the correct size of an int. The sample terminal session run program (at least) fourtimes. Have program convert the values -1, 195934910, 65535,and 65536.

Explanation / Answer

please rate - thanks I think you like this program #include using namespace std; int main() {char hex[6]={'A','B','C','D','E','F'}; int numbits,num,digits,shifted,i,j; numbits=sizeof(int)*8;   //get number of bitsconverting coutnum; while(num!=0)    {cout>i;    //shift to theright        shifted=shifted&1;    //use mask to get rightmost bit        cout