Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

The Type int [12/14]

The modulo operator %% returns the remainder of the integer division operation.

The expression 9 %% 4 evaluates to value 1 because 9 divided by 4 equals 2 with reminder 1.

The expression 3 %% 4 evaluates to value 3 because 3 divided by 4 equals 0 with reminder 3.

When the left operand of operator %% is divisible by the right operand, the result is 0. For example, 15 %% 5 evaluates to 0, 21 %% 7 evaluates to 0 and 6 %% 6 evaluates to 0.

The result of operator %% is always an integer.

Loading...