Both f() and g() are passed to printf as arguments and each increments the same global counter. What does standard C guarantee about the values printed?
Ag() always runs first, because the arguments are evaluated right to left
BNothing; the calls are indeterminately sequenced, so either order can occurCorrect answer
Cf() always runs first, since it appears leftmost in the argument list
DThe program has undefined behaviour, because one global object is written twice
Correct answer
B. Nothing; the calls are indeterminately sequenced, so either order can occur
Function argument evaluation order is unspecified in C: the compiler may evaluate f() or g() first, and the two calls are indeterminately sequenced with respect to each other. Because the increments are not unsequenced side effects on the same scalar, the program is not undefined, only output-dependent, so no single printed order can be relied on. Contrast this with i = i++, where two unsequenced writes to one object are genuinely undefined behaviour.