Can you explain my program

hi , can you explain this program when there is " double averagearray ( int* arr, int number);"

#define SensorPin A0 //pH mètre en sortie A0
#define Offset 0
#define LED 13
#define samplingInterval 20
#define printInterval 800
#define ArrayLenth 40
int pHArray[ArrayLenth];
int pHArrayIndex=0;
void setup(void)
{
pinMode(LED,OUTPUT);
Serial.begin(9600);
Serial.println("pH de la piscine : ");
}
void loop(void)
{
static unsigned long samplingTime = millis();
static unsigned long printTime = millis();
static float pHValue,voltage;
if(millis()-samplingTime > samplingInterval)
{
pHArray[pHArrayIndex++]=analogRead(SensorPin);
if(pHArrayIndex==ArrayLenth)pHArrayIndex=0;
voltage = avergearray(pHArray, ArrayLenth)5.0/1023;
pHValue = 3.5
voltage+Offset;
samplingTime=millis();
}
if(millis() - printTime > printInterval)
{
Serial.print(" Valeur du pH: ");
Serial.println(pHValue,1);
if (pHValue < 7){
Serial.println(" Votre pH est Acide , rajoutez du pH+");
}
else{
if (pHValue > 7.8){
Serial.println(" Votre pH est Basique , rajoutez du pH-");
}
else{
Serial.println(" Votre pH est bon.");
}
digitalWrite(LED,digitalRead(LED)^1);
printTime=millis();
}
}
}
double avergearray(int* arr, int number){
int i;
int max,min;
double avg;
long amount=0;
if(number<=0){
Serial.println("Erreur/n");
return 0;
}
if(number<5){
for(i=0;i<number;i++){
amount+=arr*;*

  • }*
  • avg = amount/number;*
  • return avg;*
  • }else{*
  • if(arr[0]<arr[1]){*
  • min = arr[0];max=arr[1];*
  • }*
  • else{*
  • min=arr[1];max=arr[0];*
  • }*
  • for(i=2;i<number;i++){*
    _ if(arr*<min){_
    _
    amount+=min; //arr<min*_
    _ min=arr*;
    }else {
    if(arr>max){
    amount+=max; //arr>max*

    max=arr*;
    }else{
    amount+=arr; //min<=arr<=max*

    * }
    }//if*

    * }//for*
    * avg = (double)amount/(number-2);
    }//if*

    * return avg;
    }*_

Welcome. Please take the time to read the post by Nick Gammon at the top of this Forum for guidelines on posting here, especially the use of code tags when posting source code. It will help us help you.

I can't see the point of calculating max and min inside "your" function, because you never return those values.