hi guys,i tried this thing on my turbo c compiler...actually my frnd asked me for theoutput for the code...

this is the code....

Code:
 #include<stdio.h>
 #include<conio.h>
  void main()
 {
   int i=10;
   i=(i++)/(i++);
   printf("%d",i);
   getch();
 }
i got the output as 3
apparently...the compiler is calculating i/i first and the incrementing i 2 times....but........if i directly say

Code:
printf("%d",i++/i++);
it does not give me the same result
actually wat i want to ask is this....
when a division is output directly in printf,as in the case that i have give,it calculates the numerator first and then the denominator...bt,if i calculate for the division inside the main() func,and then assign the value to a variable

say something like

case 1:
Code:
b=i++/i++;
i get the output as 1,

whereas,if i say

case 2:
Code:
 printf("%d",i++/i++);
i get the o/p as 0;

in the first case i think it is doing wat is to be done in the denominator first and then goin on to the numerator...

bt in the second one .... it does wat is in the numarator first...and then goes on to the denominator...


y does the compiler have double standards while calculating in different conditions....

any help is appreciated...

p.s.i also tried it out in the borland compiler...and got the same results...

ciao