Practice mode C Language

In the call printf(“%d %d”, f(), g());, what does the C standard say about which function is called first?

Correct answer D. The order is unspecified, so either may be called first

Explanation

The evaluations of function arguments are unsequenced relative to each other, so the order is unspecified and may differ between compilers or optimisation levels. There is a sequence point before the actual call, so all arguments are complete by then. If f and g have side effects that matter, call them in separate statements and store the results first.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.