## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

### The Modulus Operator (%)

The modulus operator, represented by the percent symbol ((%), is the last unmentioned binary operator of Table 7.1. The modulus operator has the same precedence as the division and multiplication operators. It can only be used with integer numbers and returns the remainder of dividing the first (left) operand with the second (right) operand. For example 20 % 7 is 6 because 7 goes into 20 two times, 2 * 7 = 14 and 20 - 14 = 6, which is the remainder. An often-used algebraic notation to denote a modulus calculation is the abbreviation mod. Thus, 20 % 7 in mathematics is often written 20 mod 7. Table 7.2 gives an overview of the five binary operators and how typical arithmetic expression are written in C#.

Table 7.2. The ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required