The modulo (%) operator calculates the remainder of a division operation. In this case, it calculates the remainder of i divided by 2. If i is an even number, the result will be 0 and if it is an odd number, the result will be 1. So this if statement checks to see if i is an even number.
Answers
The modulo (
%
) operator calculates the remainder of a division operation. In this case, it calculates the remainder ofi
divided by2
. Ifi
is an even number, the result will be0
and if it is an odd number, the result will be1
. So thisif
statement checks to see ifi
is an even number.Another l33ter way to check for odds & evens is: $-)
In programming, experimenting is a good way to understand:
look also a the reference on http://www.processing.org