The evaluation order does matter a lot, so, is this something called non-referential-transparency?
int i = 1;
int counter(){
i = i + 1;
return i;
}
int foo(int i, int j){
return i*2 + 3*j;
}
int main(){
printf("%d", foo(counter(), counter()));
}
I guess what you might have in mind is that the evaluation order of function parameters is not standardized in C. Since
counter()will return a different result on each call, and the result offoo(2, 3)is different from that offoo(3, 2), compiling and executing this code may give you different results on different platforms.On the same platform, however, it is deterministic, as others have explained well. [Update] (To be precise: once compiled into an executable on a specific platform with specific compiler options, all executions will produce the same output. However, as commenters pointed out, it might even produce different output on the same platform when built with different compilation options.)[/Update]