Java has one important arithmetical operator you may not be familiar with, %, also known as the modulus operator.The modulus operator,
% returns the remainder of a division operation. e.g., 15 % 4 = 3, 7 % 3 = 1, 5 % 5 = 0
![]() As shown above, when we divide 17 (dividend) with 3 (divisor) then the quotient is 5 and the modulus (or remainder) is 2 .
Find Modulus CODE class FindModulus OUTPUT x mod 10 = 2 DESCRIPTION When 32 is divided by 10, the quotient will be 3 and the modulus (or remainder) will be 2. Similarly when 36.75 is divided by 10, the quotient will again be 3, where as the modulus will be 6.75. 2-min video about modulus operator
|