Original author: John Clements

The first step in any programming task is to think about the kinds of data that you need, and the first step in learning a new programming language is to understand the kinds of data that it can represent. These are called "values." In C, the most basic set of values are the whole numbers, or "integers." 13 is an integer, and so is 0. Try entering an integer in this box:

Secret Note for Especially Advanced People: Are there things that you expect to be integers that aren't? See if you can figure out why negative numbers don't parse (i.e. get interpreted) as integers.

The C language has a variety of boolean operations, including addition (+), subtraction (-), multiplication (*), and division (/). Make sure you can find all of these on the keyboard. These operators behave more or less as you might expect, with a few gotchas. To add

`3`

and `4`

together, for instance, you can write `3 + 4`

.
Write an arithmetic expression that uses addition to add two numbers:
`4 / 2`

, but when the denominator
does not evenly divide the numerator,
C rounds toward zero. (What if one is negative? Don't ask. Please.)
Okay, quiz time: fill in the integers that result from the following division operations:
`10 / 5`

`9 / 4`

`3 / 12`

Like normal mathematical notation, multiple elements may be joined together using arithmetic operators. For instance

`3 + 4 + 5`

is a fine expression, and
so is `20 * 14 * 3`

.
Write the C expression that adds fifteen, sixteen, and twenty-three:
`(20 / 19) / 19`

does not produce the same value as
`20 / (19 / 19)`

. In this case, C's default is to be "left-associative";
that is, the leftmost operator binds more tightly. So the expression
`20 / 19 / 19`

is evaluated as `(20 / 19) / 19`

.
What if that's not what you want? Well, you can use parentheses-as in the examples
above-to get the meaning you want.
Combining different operators is also possible, and gives rise to similar questions.
For instance, the expression `3 + 4 * 5`

might evaluate either to 35 or to 23.
In this case, C uses rules of "precedence" to determine which operators "bind more
tightly". C follows the standard convention that operators such as multiplication and
division have higher precedence than addition, so `3 + 4 * 5`

evaluates
to 23.
Precedence rules and associativity are complex; in general, the best advice is simply
to parenthesize whenever you're unsure.
Translate the given English into a C expression, and then enter the expected integer result: