1,511 views

Which of the following is the correct order of evaluation for the below expression?

$z=x+y^*z/4\%2-1$

1. $^*/\%+-=$
2. $=^*/\%+-$
3. $/^*\%-+=$
4. $^*\% /-+=$

### 1 comment

According to Operator precedence ‘,’ operator has less precedence among all operators then comes ‘=’ operator.

’*, / %’ same priority but it execute left to right. Similarly ‘+,-’.

z=x+y∗z/4%2−1

Basically left to right order is *,/,%,+,-,=

precedence order of *,/,% are same and associativity is left to right so */% and similarly for +,- order are same and associativity is left to right and at last = has least precedence among them so it will be evaluated at last.

So (A) should be correct option.

A is the correct answer according to precedence

1 vote
1
569 views