Modulus Operator:  %

The result of the modulus operator (%) is the remainder when the first operand is divided by the second.

Example

In the following example, the modulus operator is used to determine if the numeric value 4 evenly divides into nCenturyYear. If the remainder is zero, the nCenturyYear must be a leap year, so the LeapYearFunction() is executed.

// Example of the modulus operator
int nCentury;

if ((nCenturyYear % 4) == 0) {
      LeapYearFunction();
}