Question: Write a C++ program that prompts the user to input an unsigned value for an unsigned short variable x, doubles x sixteen times using the

Write a C++ program that prompts the user to input an unsigned value for an unsigned short variable x, doubles x sixteen times using the left shift operator, and prints the x each time. (Hints: 1. to declare an unsigned short variable, you can use unsigned short int or u_int16 as variable type 2. to double the variable value, you can apply shift 1 bit left using <<)

Sample output:

Enter an unsigned value: 1

2

4

8

...

32768

0

Test your program for input 1. Did you see the same output as above?

1. Upload your cpp file here. (3pt)

2. Take a screenshot of your program, compile, run statements for input 25 and its output, and paste them here. (5pt)

3. Interpret the output that your program prints. Are all the written results correct? If not, write here what the reason is for the wrong results. (3pt)

Change your x data type as short int or int16 and run your program again for input 25.

4. Take a screenshot of the result (3pt) and interpret the output that your program prints. Are all the written results positive? If not, write here what the reason is for the negative results. (3pt)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!