Since the array must have been declared as a global variable somewhere, I would use
Code:
unsigned int store[8];
char index;
unsigned int mval;
// ...
//------------------------------------------------------
void takeaverage()
{
mval = 0;
for (index=0; index<8; index++)
mval += store[index];
mval /= 8;
return;
}
//------------------------------------------------------
After calling the function, the mean value is stored in mval and you can convert it to signed int (cast), if you want.