### Oops... Use Care When Evaluating A - B + C

A mathematical expression came up during class that GDT should have spent more time discussing.

```   Evaluate:  20 - 10 + 6

Subtraction and addition have equal precedence;
therefore, evaluate left-to-right.

step 1) 20 - 10 = 10
step 2) 10 + 6 = 16

20 - 10 + 6 = 16
```

Order of operations are still applicable when processing operators of equal precedence.

```   Evaluate:  20 - 10 + 6

If the addition is done before the subtraction, then
the expression becomes 20 - (10 + 6).

step 1)  10 + 6 = 16
step 2)  20 - 16 = 4

20 - 10 + 6 != 20 - (10 + 6)

In English, 20 minus 10 plus six is not equal to
20 minus the quantity 10 + 6.
```

Writing subtraction as addition can help ensure operations are executed in the correct order.

```   20 - 10 + 6 = 20 + (-10) + 6

Because the commutative and associative properties hold
true for addition, order of operations is not significant.

Commutative property:  a + b = b + a
Associative property:  a + (b + c) = (a + b) + c

Some examples...

20 + ((-10) + 6) = (20 + (-10)) + 6
20 + ((-10) + 6) = 20 + (6 + (-10)) = ((-10) + 6) + 20
```
##### Exercises
1. Evaluate: 24 / 12 * 6

2. Evaluate: 30 - 10 + 20 - 10

3. Evaluate: 50 - 10 + (10 - 5)

Creator: Gerald Thurman [gthurman@gmail.com]
Created: 07 February 2007 This work is licensed under a Creative Commons Attribution 3.0 United States License.