From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Solution: Get the order correct

Solution: Get the order correct - C Tutorial

From the course: Complete Guide to C Programming Foundations

Solution: Get the order correct

(upbeat music) - [Instructor] I hope you appreciate the descriptive variable names used in the challenge exercise file. Programmers who write good code use names such as these. No confusion. Starting here, we're going to assign the variables. First, assign 12 to variable rooms. (computer keys clicking) Next, 16 to variable paintings. (computer keys clicking) And to variable sculptures, four. (computer keys clicking) To calculate the number of artifacts, I will craft this expression. (computer keys clicking) The calculation inside the parentheses happens first. The value of paintings is added to sculptures. Once this value's obtained, the equation works left to right, with rooms multiplied by the results of the operation in parentheses. Run to see the answer. The museum has 240 artifacts. If you omit the parentheses, rooms is multiplied by paintings first, and then the result is added to sculptures, which yields the incorrect result. Here you see the value 196, which isn't correct…

Contents