We are about to switch to a new forum software. Until then we have removed the registration on this forum.
int numbers = 10;
float [] x = new float[numbers];
float f = 0;
void setup() {
populate();
}
void populate() {
for (int i = 0; i < numbers; i++) {
float x = int(random (0,100));
println(x);
}
}
this is what i have so far and i have the task of finding the average of the array using a float variable, how do i do this?? i can't figure it out for the life of me.
Answers
Please, when posting code, highlight it and hit CTRL+K in order to format it for the forum here! [-(
thanks, sorry its my first time posting and i was rushing, i dont want it to return the value of the average i just want it to save the average
I don't get it. Either you want the final average or the early sum:
return sum/arr.length; // returns array's sum average.
return sum; // returns array's sum.