Sample Algebraic and C++ Expressions
Now consider several expressions in light of the rules of operator precedence. Each example lists an algebraic expression and its C++ equivalent. The following is an example of an arithmetic mean (average) of five terms:
The parentheses are required because division has higher precedence than addition. The entire quantity
( a + b + c + d + e ) is to be divided by
The following is an example of the equation of a straight line:
No parentheses are required. The multiplication is applied first because multiplication ...