Is left-to-right or right-to-left order guaranteed for operator precedence? Ans. The simple answer to this question is neither. The C language does not always evaluate left-to-right or right-to-left. Generally, function calls are evaluated first, followed by complex expressions and then simple expressions. Additionally, most of today's popular C compilers often rearrange the order in which the expression is evaluated in order to get better optimized code. You therefore should always implicitly define your operator precedence by using parentheses. For example, consider the following expression: a = b c/d / function_call() * 5 The way this expression is to be evaluated is totally ambiguous, and you probably will not get the results you want. Instead, try writing it by using implicit operator precedence: a = b (((c/d) / function_call()) * 5) Using this method, you can be assured that your expression will be evaluated properly and that the compiler will not rearrange operators for optimization purposes. - Study24x7
Social learning Network
15 Mar 2023 10:45 AM study24x7 study24x7

Is left-to-right or right-to-left order guaranteed for operator precedence? Ans. The simple answer to this question is neither. The C language does not always evaluate left-to-right or right-to-left. Generally, function calls are evaluated first, followed by complex expressions ...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles