Question: ( Use printf function to display ) Define a signed integer a = 0 xA 5 3 C 0 E 6 0 and an unsigned

(Use printf function to display) Define a signed integer a =0xA53C0E60 and an unsigned integer b =0xA53C0E60.
a. Print both a and b in decimal format.
b. Shift both a and b right by 4 bits and print the outputs in hex and decimal format.
Divide both a and b by 16 and print the answers in hexadecimal and decimal formats. Manually check if the results of shift right and that of division match for both a and b and if the results are correct.
c. Repeat the steps in part b with signed integer p =0xA53C0E62 and unsigned integer q =0xA53C0E62. Check if results match in both cases. Are the results correct ?
d. Define a signed integer x =0x053C0E60 and an unsigned integer y =0x053C0E60.
Shift x and y left by 4 bits and print the outputs in hexadecimal and decimal format. Multiply x and y by 16 and print the answers in hexadecimal and decimal. Manually check if for each case, the results of shift left and that of multiplication match for both a and b and if the results are correct.
d. Try the same steps as in d with signed integer x =0x0A3C0E60 and unsigned integer y =0x0A3C0E60. Manually check if the results of multiplication and left shift match. Are the results correct ?
More information -
Int is signed by default. Hence
int a; // Declares a as a signed integer
unsigned int b; // Declares b as an unsigned int
For printing - in radix 10-
Signed integers are printed with %d, unsigned integers are printed with %u.
In radix 16, it stays the same %x, since the representation stays the same, its interpretation changes.

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!