#define debug false
float price [10];
void fill(void)
{
int i;
for(i=0;i<10;i++)
{
if (debug == true )
{
price[i]=100;
}
else
{
price[i]=random(0,150);
}
}
}
void print(void)
{
int i;
for(i=0;i<10;i++)
{
Serial.print(i);
Serial.print(" ");
Serial.println(price[i]);
}
}
void printAvg(void)
{
int j;
float avg=0;
for(j=0;j<10;j++)
{
avg=avg+price[j];
}
avg=avg/10;
Serial.println("----------------------");
Serial.print("Avg : ");
Serial.println(avg);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Array start");
fill();
print();
printAvg();
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}