On 12/17/09, W.H. Kalpa Pathum <callkalpa@xxxxxxxxx> wrote: > Could you please explain how the output differs (when assigned to the > variable b and in printf statement) and the way the compiler executes > each segment of the variable? > > int main(){ > int a = 10; > int b = (++a) + (++a); > printf("%d %d %d %d\n", b, a++, a, ++a); > printf("%d %d %d %d\n", ++a + ++a, a++, a, ++a); The program evaluates the arguments first and calls printf then. You can't do such things if you want to rely on the result, because the order of the arguments evaluation is implementation-specific (to begin with).