0
I don't understand what the % do?
4 Respostas
+ 4
% is a modulus operator, and it is used to return the remainder of a division.
For example:
5 % 2 = 1
10 % 5 = 0
30 % 7 = 2
A very common, and beginner way to use the modulus is to tell whether or not a number is even:
if (x % 2 == 0)
{
//even
}
else
{
//odd
}
+ 1
25:3=8 rest 1
explication:
25/3=8
25%3=1
0
it returns the remainder
0
Yeah, all it does is to return the remainder.