C Programming MCQ

1: If the following program fragment(assume negative numbers are stored in 2's complement form) unsigned i=1; int j=-4; printf("%d",8*size of(int)); output is (log in answers are to the base two)
A. An unpredictable value
B. 8*log(x+3)
C. log(x+3)
D. None of these
 

Answer : C

Explanation :
Let size of (int)=1. So, -4 will be stored as 11111100. Since we are adding unsigned and signed integers the signed gets converted to unsigned. So, i + j will become 11111101. We are trying to print this as an unsigned integer.
So, what is printed will be 2⁸-1-2. So, log (x+3)=8(i.e,*size of (int)).

barbee doll said: (12:10pm on Tuesday 8th August 2017)
Please explain it that how -4 will be stored in 11111100 form while 4 binary form is that 00000101

Write your comments here:


Report Error
 

Option: A

Explanation : Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here.