Code

background(220);
size(425,100);
noStroke();
fill(0);
smooth();

for (int i=100; i<350; i+=25){
  if (i==175){
    fill(255,0,0);
  }
  else{
  fill(0);
  }  
  ellipse(i, 50, 20,20);
}

0207 - Conditionals within a for{} loop I: Combining if{} and for{}

Statement:Embed an if{} structure within a for{} loop in order to produce the design shown here:



Hint: Set up a counting variable x which counts ten times, and is used to govern the position of the circles. Then set the fill color to red if x is equal to the fourth count, but otherwise set the fill color to black. For your consideration: Does your code make it easy to change the spacing between the circles? If you change the spacing of the circles, do you need to change the equality test as well?

hide statement