0
Can someone explain me operator precedence in detail?
2 odpowiedzi
+ 6
Operator Precedence in C
Operator precedence determines which operator is evaluated first when an expression has more than one operators. For example 100-2*30 would yield 40, because it is evaluated as 100 – (2*30) and not (100-2)*30. The reason is that multiplication * has higher precedence than subtraction(-).
you can check this one...
https://www.google.com/amp/s/www.geeksforgeeks.org/theory-computation-operator-grammar-precedence-parser/amp/
Thanks.
0
In operator precedence(priority or importance)we have
*,/,+,%,- operators
In which /*% have equal priority and
-+ have equal priority
But among them */% have higest priority than +-
-------------------------------------------
Equation statement is executed from LEFT to RIGHT after = sign.
a=5+1*2
Output :a=7
Because from Left to RIGHT
* has highest precedence than +
-------------------
If we want to execute any part of equation first then we right them in () parenthesis.
E.g. b=(5+1)*2
Output: b=12