VOOZH about

URL: https://www.geeksforgeeks.org/c/evaluation-order-of-operands/

⇱ Evaluation order of operands - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Evaluation order of operands

Last Updated : 31 Mar, 2021

Consider the below program. 
 

Output: 
 

10


What would the output of the above program - '5' or '10'? 
The output is undefined as the order of evaluation of f1() + f2() is not mandated by standard. The compiler is free to first call either f1() or f2(). Only when equal level precedence operators appear in an expression, the associativity comes into picture. For example, f1() + f2() + f3() will be considered as (f1() + f2()) + f3(). But among first pair, which function (the operand) evaluated first is not defined by the standard. 
Thanks to Venki for suggesting the solution.
 

Comment
Article Tags: