Code
size(400,100);
background(255);
smooth();
noStroke();
int spacing = 30;
for (int i=1; i<=10; i=i+1){
if (i%3==1){
fill (255,0,0);
}else {
fill (0);
}ellipse (50+ i*spacing, 50, 25,25);
}
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: