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 - C Tutorial
From the course: C Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Working with math operators3m 3s
-
(Locked)
Challenge: Do some math49s
-
(Locked)
Solution: Do some math1m 29s
-
(Locked)
Using assignment operators1m 44s
-
(Locked)
Obeying the order of precedence3m 13s
-
(Locked)
Challenge: Get the order correct54s
-
(Locked)
Solution: Get the order correct1m 11s
-
(Locked)
Working with relational operators3m 39s
-
(Locked)
Using logical operators3m 49s
-
(Locked)
Understanding bitwise operators3m 36s
-
(Locked)
Shifting bits3m 18s
-
(Locked)
Exploring unary operators3m 44s
-
(Locked)
Challenge: Binary math1m 5s
-
(Locked)
Solution: Binary math2m 11s
-
-
-
-