Main(){ char c; int i = 456; clrscr(); c = i; printf("%d", c);}

A) none of the above
B) random number
C) -456
D) 456
Explanation: Answer is -56

Showing Answers 1 - 2 of 2 Answers

chandhi

  • Feb 12th, 2006
 

Could u plz  exp how  did u get this ans?????

  Was this answer useful?  Yes

paulson paul chambakottukudyil

  • Apr 19th, 2006
 

See.........

converting 456 to binary, we get 111001000.

it takes more than one byte. Se when we assign c=i, the most significant will be lost. Then the value of c is 11001000. when you print the value of c using %d(signed integer), the most significat bit will be considered as the +/-. Here it is 1 and hence the number is negative. Negative numbers are in 2's compliment form. so converting back, we will get 00111000. ie, -56 in decimal. if you used %u instead of %d, you could have got 200.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions