Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# Help with arrays

Shawn Houston
Greenhorn
Posts: 22
Ok i have a program that takes 4 orchards over a 5 year span. I need to get the average of each orchard. Which I have..now i need to get the Total of the 4 orchards for each of the 5 years..then the average for each year which I'm having a real trouble doing.

I just can't seem to get the totals for each seperate year and the averages.
What i thinking is I have to:
for(i = 0; i < 4; i++) {
for(j = 0; j < 5; j++)
year_total[i] += peach[0][0] +peach[0][1] + peach[0][2] + peach[0][3];
year_avg[i] = (float)(year_total[i] / 4.0);

For each consecutive year..but when i do that it adds both years then averages them. Not sure where I'm going wrong here nor how to put all the years into 1 for statement if its even possible.

Jimmy Die
Ranch Hand
Posts: 97
Hi,

Something a little different but a little the same:

[ November 29, 2004: Message edited by: Jimmy Die ]