Arithmetic Operators
These are +, *, -, and / for addition, multiplication, subtraction, and division. That's about it.
There is also the modulus operator, which looks like this: %. If you can't remember modulus, which actually comes in handy with surprising frequency, it is used to return the remainder of performing a division operation.
For example, 10 % 3 = 1, because 10 divided by 3 is 3 (which we don't care about) with a remainder of 1 (which is what we care about when we use modulus).
There's one more thing: you can use a special shorthand in combination with any of the arithmetic operators (excluding modulus) to modify an existing value.
Say you have a variable of type int called x and its value is 0, and you want to add 1 to it. You can ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access