Code
background(220);
size(425,100);
noStroke();
fill(0);
smooth();
int spacing=25;
for (int i=0; i<=9; i++){
if (i%3==0){
fill(255,0,0);
}
else{
fill(0);
}
ellipse(100+spacing*i, 50, 20,20);
}
0209 - Conditionals within a for{} loop III: if{} and the % operator
Statement:For this assignment, you are limited to a single for{} loop and a single if{} structure.
Set up the placement of ten circles using a single for{} loop, as you have done in the previous two assignments. (In this particular exercise, it may be easiest if the counting variable of your for{} loop counts from 0 to 9).
The modulus operator (%) is useful for determining whether a number is an round multiple of some other number. For this assignment, use the modulus operator and an if{} structure to color every third circle red. Circles representing counts which are not a multiple of 3, should be filled black.
Here is what your result should look like: