Sunday, March 05, 2023
SP LAB ASSIGNMENT 2 @ DR A R NASEER
P a g e
|
9
Q13) a) Express the following Decimal numbers in Two’s Complement binary
form assuming that these numbers are stored in 8-bit registers
(i) -9
(ii) -18
(iii) -27
(iv) -84
(v) -127
(vi) -1
b) Perform the following shift operations on the above numbers and write
the result in both decimal and binary form. Also indicate whether the
obtained result is correct. If not, state the reason.
i) Logical shift left by 1 bit
(ii) Logical shift left by 2 bits
iii) Logical shift left by 3 bits
(iv) Logical shift left by 4 bits
v) Logical shift right by 1 bit
(vi) Logical shift right by 2 bits
vii) Logical shift right by 3 bits
(viii) Logical shift right by 4 bits
ix) Arithmetic shift right by 1 bit (x) Arithmetic shift right by 2 bits
xi) Arithmetic shift right by 3 bits (xii) Arithmetic shift right by 4 bits
xiii) Arithmetic shift left by 1 bit (xiv) Arithmetic shift left by 2 bits
xv) Arithmetic shift left by 3 bits (xvi) Arithmetic shift left by 4 bits
PART – B : C PROGRAMMING
Q14) Write a C program to read a string representing binary number (a sequence
of 1s & 0s – maximum 32 bits) from the keyboard and convert this binary
number to
(i) Unsigned form
(ii) Signed Magnitude form
(iii) One’s Complement form
(iv) Two’s Complement form
(v) Octal form
(vi) Hexadecimal form
For Example :
Input -
Enter a Binary Number
:
1111111101011111
Output –
B2U(1111111101011111) =
65375
B2S(1111111101011111) =
- 32607
B2O(1111111101011111) =
-160
B2T(1111111101011111) =
- 161
OCT(1111111101011111) =
177537
HEX(1111111101011111)
=
0xFF5F
1>
Do'stlaringiz bilan baham: