Output of the following programvoid main(){unsigned i;i=100*400;printf(\

Showing Answers 1 - 18 of 18 Answers

A. Dubey

  • Feb 16th, 2006
 

output will be 40000

  Was this answer useful?  Yes

srilatha

  • Feb 16th, 2006
 

the output is -25536 as the range of an integer is +25536 to -25536.

so the value of i cannot be maore than the range .so after 25536 it goes to negative values.

  Was this answer useful?  Yes

Abhishek

  • Feb 18th, 2006
 

integer range is -32767  to  32768  however  var i cannot take negative values  because it is unsigned.

  Was this answer useful?  Yes

sucheta

  • Feb 22nd, 2006
 

i say that the range of the unsigned integers is 0 to 65535. so the output may be 40000. please reply if the answer is correct.

Richa Yadav

  • Feb 23rd, 2006
 

garbage value is print becoz the range of integers is from -32768 to 32767

  Was this answer useful?  Yes

ravindra

  • Mar 7th, 2006
 

yes u r correct 40000 is unsigned intergers range from 0 to65535,see predefined function UNSIGNED INT_MAX.

novicecoda

  • Mar 10th, 2006
 

for %d,the output is -25536 (as srilatha rightly said), since %d is for signed int, and 40000 falls in the range.for %u,it will be 40000, since the range for unsigned starts from 0.(correct me if iam wrong, anyone)Rohit

  Was this answer useful?  Yes

novicecoda

  • Mar 10th, 2006
 

The output for %d, i.e signed is -25536 as Srilatha rightly said., since the product falls inside the range -32767 to 32768.FOr %u , unsigned the range starts from 0, output is 40000.Rohitp.s: correct me if im wrong any1.

  Was this answer useful?  Yes

abhishek

  • Mar 12th, 2006
 

smebdy  please check they have not mentioned data type(unsigned char or int or what)......

it will give error i guess

plz rply

Santosh Reddy

  • Apr 12th, 2006
 

HI,

The output depends on the format specifier you are using to print,

if you use 

printf("%d",i);         output: -25536

printf("%u",i);         output: 40000

declaring the variable as unsigned does't decide the value, it will also differ depending on the format specifier( %d or %u ) used to print.  please let me know if is not working.

  Was this answer useful?  Yes

paulson paul chambakottukudyil

  • Apr 17th, 2006
 

If you use unsigned alone, it will be considered as unsigned int by default.

  Was this answer useful?  Yes

Shaurya Bhasin

  • Apr 23rd, 2006
 

dats not for sure...if u are using Win or Linux(i.e 32-bit OS) den ur range is from -2147483648 to +2147483648 

lohith

  • May 25th, 2006
 

sucheta u r correct, the unsigned range is 0 to 65535 , the output will be within the range only so it will print 40000

  Was this answer useful?  Yes

santhoshkumar

  • Oct 7th, 2006
 

tes sucheta you r absolutely right

even unsigned never takes -ve values and it doubles the memory by adding the whole memory capacity

  Was this answer useful?  Yes

The integer size on 16 bit machine is 2 bytes.2 bytes = 16 bits.2^16 = 65536So for unsigned int range is 0 to 65536for signed int, range is -32768 to 32767And here unsigned int is used, and 40000 is within range, so it will print 40000 without any error.(Provided that the code is complete :) )

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