#define ntemp 10
float temps[ntemp] = {19.5, 20.0, 20.5, 21.0, 21.5, 22.0, 22.5, 22.0, 21.5, 21.0};
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
// Print the initialized values for verification
for (int i = 0; i < ntemp; i++) {
Serial.print("Temperature at index ");
Serial.print(i);
Serial.print(": ");
Serial.println(temps[i]);
}
float maxTemp = temps[0];
float sum = 0.0;
for (int i = 0; i < ntemp; i++) {
sum += temps[i];
if (temps[i] > maxTemp) {
maxTemp = temps[i]; }
}
Serial.print("Sum of temperatures: ");
Serial.println(sum);
Serial.print("Maximum temperature: ");
Serial.println(maxTemp);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}