Arithmetic Operators

The C language's arithmetic operators closely resemble those in other languages. Table 6.1 lists C's arithmetic operators.

Table 6.1 Arithmetic Operators

Operator Description

* Multiplication
/ Division
% Modulus
+ Addition
Subtraction

The “modulus operator” (%) may be unfamiliar. It divides a value and gives the remainder. For instance, the statement

remainder = 20 % 3;

assigns the value 2 to the variable remainder (20 divided by 3 equals 6, with a remainder of 2). If the division doesn't produce a remainder, the modulus operator yields the value 0.