in DS retagged by
2,504 views
3 votes
3 votes

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. $^*\% /-+=$
in DS retagged by
by
2.5k views

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 *,/,%,+,-,=
3
3

2 Answers

3 votes
3 votes

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.

1 vote
1 vote
A is the correct answer according to precedence
Answer: