I am not challenging you. But I dont understand why I have to do that? What tells you that you have to calculate it outside of the loop? Am I missing something?
I am not challenging you. But I dont understand why I have to do that? What tells you that you have to calculate it outside of the loop? Am I missing something?
When you calculate an average, it's easier (but not necessary) to compute the sum, and only then divide by the number of elements, once. BTW, you've written the function to assume that the number of elements is 5. You could pass the number of elements as another argument, and then divide by whatever it is.