A mathematical operation (modulus arithmetic) in which the result is the remainder of a division. Also known as the "remainder operator," it is used to solve a variety of problems. For example, the following code in the C language determines if a number is odd or even. The number in AMOUNT is divided by 2, and the result is the remainder. If RESULT is zero, the number is even. The % symbol is the modulo, or "modulus" operator.

result = amount % 2; if (result == 0) EVEN=YES; else EVEN=NO;

All other reproduction requires permission

Copyright 1981-2021

The Computer Language Company Inc.

All rights reserved