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
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.
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.
paulson paul chambakottukudyil
Apr 17th, 2006
If you use unsigned alone, it will be considered as unsigned int by default.
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
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
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 :) )
Output of the following programvoid main(){unsigned i;i=100*400;printf(\