I need to check of a number is incremented by 10 (70, 20, 110)
example: input: (74, 21, 105) output: false
input: (70, 20, 110) output: true
I have tried if(num % 10 == 1)
I need to check of a number is incremented by 10 (70, 20, 110)
example: input: (74, 21, 105) output: false
input: (70, 20, 110) output: true
I have tried if(num % 10 == 1)
The remainder operator (%
) is indeed what you're looking for.
The binary operator
%
yields the remainder of the division of the first operand by the second (after usual arithmetic conversions).
The remainder you're looking for is zero, not one. Therefore the correct check is:
if(num % 10 == 0)