Pulse Sensor - Average of 10 Latest BPM using array

Hi guys, I would like your help about how to use array to save the 10 latest BPM so that I could make an average, I'm doing my final project now , I really appreciate if you guys could help , thanks

BPM ? beats per minute ?
It sounds like an application for a circular buffer. Untested / unoptimised . . .

int index = 0 ;
const int bufferSize = 10 ;
int buffer[ bufferSize ] = {0} ;
float average ;
. . .
loop() {

  // load buffer
  buffer[ index ] = myInput ;
  index ++ ;
  if ( index >= bufferSize ) {
    index = 0 ;
  }

  // average
 float average = 0 ;
  for ( int j = 0 ; j < bufferSize ; j++ ) {
     average += buffer[ index ] ;
  } 
  average = average / bufferSize ;

}

float average = newSample * 1.0/10 + average * 9.0/10;