 How does C evaluate arithmetic expressions? Let's look at this expression and find out how it works. C evaluates expressions in priority order. Operators at the same level of priority, also called precedents, are evaluated from left to right. In this expression, working from left to right, the highest priority operation is the multiplication of 4 times 5. That gives us 7 plus 20 minus 6 divided by 2. The remaining highest priority operation is 6 divided by 2, which gives us 7 plus 20 minus 3. Everything remaining is at the same level of priority. 7 plus 20 is 27 minus 3 gives us 24. Let's build the program and run it. And indeed, there's our answer, 24. Here's one operator you may not be familiar with, the percent sign operator. It means remainder after integer division, and it's called mod or modulo. Here's a program that takes a total number of units and breaks it into dozens and units by dividing by 12 and taking the remainder upon division by 12. We calculate the dozens, the quotient, in line 18. Integers divided by integers always gives an integer result with no decimal places. We calculate the remaining units by using the modulo operator, on line 19, and we print the result on line 21. Let's build the program and run it, and it gives the correct results. What about using doubles in arithmetic expressions? What happens when you use doubles and integers together in an arithmetic expression? Here's a program that gives examples of exactly that. When you take an integer divided by an integer, you always get an integer result. Double divided by double always gives a double result. When you divide a double by an integer, or an integer by a double, the integer gets promoted to a double, and the result will be a double. Let's build this program and run it, and there's the answer. Let's look at this program that calculates the average number of raffle tickets sold per person, and we'd like a decimal result for the average. We take the total tickets, an integer, the number of people, also an integer, and then set the average to the tickets divided by a number of people. This should come out to 6.375. Let's build it and run it, and the decimal points aren't there. Why did that happen? Remember how assignment works. The right-hand side is completely evaluated first. We have an integer divided by an integer. 51 divided by 8 gives integer 6. Now we look at the left-hand side and promote that 6 integer to a double 6.0, and that's why it printed out 6.0 as our answer. If we want the division to have decimal points, at least one of these operands has to be a double. We can't make a variable name a double by adding 0.0 at the end of it. That won't work. But what we can do is something called a cast. What we need to do is to change the shape of one of those integers into a double, and the way we do it is by putting in parentheses the data type we want to cast to before the variable name. You can think of a cast in the same sense as casting metal into a mold to change its shape. When C looks at this expression, it will take total tickets, which is an integer, promote it to a double. Now we have a double divided by an integer, which gives us a double result, 6.375, which will be assigned to the double average. Let's rebuild and execute, and now we have the correct answer. By the way, you can also cast both of the operands to double, and we'll get the same result. Should you cast both operands or only one? It depends on how specific you'd like to be. In summary, arithmetic expressions are evaluated from left to right in priority order. The modulo operator gives you the remainder upon integer division. When you have operands that are integer and double, the integer is always promoted to a double before the operation is applied. And if you need to convert an integer to a double, you can do so using a cast.