Use of "%" operator in this way.

I need a little help in understanding this, if someone could.

if ((iii % 3)==0)

I was told that if iii was divisible by 3 the if statement would return true.

I don't understand what the % dose in the equation.

Last edited on
closed account (zb0S216C)
It's the modulus operator: its job is to divide the left operand by the right operand and then return the remainder. For example, 7 % 3 is 1 because 3 goes into 7 twice but the 1 is left over.

Last edited on
Topic archived. No new replies allowed.