Lesson 5: Order of Operations

[spoiler title=”Lesson Video”]
Direct Download of Video (For mobile / offline viewing)(right click > save target as)


[/spoiler]

[spoiler title=”Lesson Source Code”]

[/spoiler]

Homework: http://beginnerscpp.com/forums/index.php/topic,59.0.html



Order of Operations
The order of operations in C++ is as follows:

  1. Parenthesis / Functions
  2. Multiplication / Division (left to right)
  3. Addition / Subtraction (left to right)

Therefore using these rules we can discern that C++ would resolve the following equation:

7+(6*3-2)*2
Would resolve to 39– 18-2 = 16*2 = 32 +7 = 39