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 ofidivided by2. Ifiis an even number, the result will be0and if it is an odd number, the result will be1. So thisifstatement checks to see ifiis 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