you can declare and define const variable 'average' inside the loop. Don't be afraid, compiler optimize it.