From the course: C Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Obeying the order of precedence

Obeying the order of precedence - C Tutorial

From the course: C Essential Training

Start my 1-month free trial

Obeying the order of precedence

- You've seen these puzzles on social media. What's the result of this equation? People have different answers and quarrels erupt over who is accurate. One answer is definitely correct. And you'll know it, When you understand the order of precedence. Here's the order for mathematical operations in the C language. Work the equation left to right. If the equation contains any expression in parentheses, calculate it first outside of parentheses before multiplication and division moving left to right, then perform addition and subtraction moving left to right. Not only do these rules help you dominate social media, they help you construct proper expressions in your C code as well. This code contains the infamous internet puzzle shown earlier, build and run to see who's right, and who's wrong. Okay, mystery solved. So working left to right six divided by two is three, multiplied by the result of one plus two which is…

Contents