As , we have given a=2
Now what is ~a ?
it is the Bit-wise NOT operator(~) which gives the complement .
so here ~a = -(a+1)
i.e ~a = -(3)
now,
~a + 2 = -3 + 2 = (-1)
AS ,it is given in question that all the negative numbers are stored in 2’s complement representation
so 2’s complement of (-1) is
(1111 1111) which is (255) in decimal notation.
moving further,
now we have to do left shift on 255.
[255 « 1]
which is nothing but 255 * 2^1 = 510
so in binary ( 1111 1110)
for the final output we have to again take 2’s complement of 510
which is (0000 0010) and (2) in decimal notation.
and as the MSB is 1[in binary notation of 510] thus negative sign must be present.
hence ,
ANS = (-2)