Arrays and for loops
in
Programming Questions
•
8 months ago
Is there a way to use for loops to make an array of number appear on the screen. Hard to explain but ill show you the code. How can I use for loops so I wouldnt have to use the text function 10 times?
int[] x= {5,88,76,54,63,89,15,66,84,155};
void setup()
{
size(200,200);
//for(int i=20; i<100; i+=20)
{
text(x[0],10,10);
text(x[1],10,30);
text(x[2],10,50);
text(x[3],10,70);
text(x[4],10,90);
text(x[5],10,110);
text(x[6],10,130);
text(x[7],10,150);
text(x[8],10,170);
text(x[9],10,190);
}
}
void setup()
{
size(200,200);
//for(int i=20; i<100; i+=20)
{
text(x[0],10,10);
text(x[1],10,30);
text(x[2],10,50);
text(x[3],10,70);
text(x[4],10,90);
text(x[5],10,110);
text(x[6],10,130);
text(x[7],10,150);
text(x[8],10,170);
text(x[9],10,190);
}
}
1