Loops using arrays

what is wrong with this code? Why does not the ellipses change colors?
<
color c[];
int x = 0;

void setup() {
size(400,400);
c[0]=color(255, 0, 0); // first color
c[1]=color(0, 255, 0); // second
c[2]=color(0, 0, 255); // third
}
void draw() {

int j = 20;

for (int i = 40; i <= 500; i = i+80 ) {
fill(c[x])
ellipse(i,100,30,80);
x = x + 1;
}
>



color[] c = new color[3];
int x;

void setup() {
  size(400, 400);
  c[0]=color(255, 0, 0); // first color
  c[1]=color(0, 255, 0); // second
  c[2]=color(0, 0, 255); // third
}

void draw() {

  int j = 20;
  x = 0;

  for (int i = 40; i <= 500; i = i+80 ) {
    fill(c[x]);
    ellipse(i, 100, 30, 80);
    x = x + 1;
    if (x>2) { 
      x=0;
    }//if
  }//for
}//func

thank you! Im also wondering what new color[3]; does

This just makes an array with 3 empty slots

Hello,

In the Processing software menu select File > Preferences…
And check the box for Continuously check for errors and Show Warnings:

When I ran your code it had some obvious errors that you could have easily corrected.

First error:

And so on…

:)

I have managed to fix it but what program or thing are your using to write code? The place I write it it also corrects code but its written too complicated to understand compared to the response you are getting.

Using this thing:
Download \ Processing.org

What thing are you using?

:)

i’m late but it is called openprocessing and I can’t download the processing you are showing because I am using a chromebook.

Hello,

In place of println() you can use console.log():

I converted C and F to strings so I could put them on one line.

:)