in DS retagged by
1,511 views
1 vote
1 vote

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
1.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 *,/,%,+,-,=
2
2

2 Answers

1 vote
1 vote

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.

0 votes
0 votes
A is the correct answer according to precedence
Answer:

Related questions