78.9k views
5 votes
Explain why A*B*C and (A*B)*C are not same

User Mr Wil
by
7.4k points

1 Answer

4 votes
The difference is in the operator precedence (order of operations) in both expressions. The result of the expression is evaluated on the basis of the different order. In the first expression, b * c is evaluated firstly, and in the second expression, the brackets facilitate the sum of a and b, followed by the multiplication by c. For example, if a = 2, b = 3, c = 4, the expressions will be evaluated as follows:

a + b*c = 2 + 3*4 = 2 + 12 = 14

(a + b) * c = (2 + 3) * 4 = 5 * 4 = 20
User Diamante
by
7.9k points