A "For" loop perhaps?!

Greetings,

I have this piece of code for calculating average and everything is kinda hard coded for the size of the array. Now I have a need to increase the array size from 3 to a 10. I wonder if anyone can assist in finding a code (a For loop perhaps) to handle this properly?

void Computation(){
  
  Array_calc[2] = Array_calc[1];
  Array_calc[1] = Array_calc[0];
  Array_calc[0] = NewValue;

  ArrayAvg = Array_calc[2] + Array_calc[1] + Array_calc[0];
  ArrayAvg = (float) ArrayAvg / 3;

}

BTFdev

A for loop would probably work better than a For loop.

Try it and see.

Anyone can point me to a sample code that does this task?

Thanks in advance.

#define SIZEOF_ARRAY(ARRAY)     (sizeof(ARRAY) / sizeof(ARRAY[0]))

void Computation()
{
    float   arrayCalc[] =
    {
          0.0f
        , 1.3f
        , 2.1f
        ... more entries here ...
    };

   const  size_t   count_entries = SIZEOF_ARRAY(arrayCalc);

    float average = 0.0f;
    for ( size_t i = count_entries; i--; )
    {
        average += arrayCalc[i];
    }

    average /= count_entries;
}