# Quick Understanding Question

Show 80 post(s) from this thread on one page
Page 2 of 2 First 12
• 04-14-2007
leopardforest@g
Do you think that will be fine? It seems like he would have made it clearer if that was the case. Right? I am not too sure... I am very new at this.
• 04-14-2007
robatino
Quote:

Originally Posted by leopardforest@g
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.
• 04-14-2007
robatino
Quote:

Originally Posted by leopardforest@g
Do you think that will be fine? It seems like he would have made it clearer if that was the case. Right? I am not too sure... I am very new at this.

If you did the loop using a pointer (say named salesp), it would be initialized to sales, then incremented to sales+1, then sales+2, ... and for each value of salesp the corresponding number would be *salesp (instead of *(sales + i)).
• 04-14-2007
Dave_Sinkula
Quote:

Originally Posted by robatino