Hi i have an array i by j big
and i want to work out averages per row and per column individually and allow the user to chose:
desired output::::
Print averages for:
1) days
2) weeks
(user then picks one... lets say days)
Average days:
Day1= 23.44
Day2= 34.56
and so on.
the days are the rows of the array and the weeks are the column of the arrays.
Here is the function that for my avrages:
thanks for your time and helpCode:Average() { int z,x,w; float avg_d,avg_w,t,f; printf (" Print averages for:\n\t1.Days\n\t2.Weeks\n\n"); scanf ("%d",z); if (z=1) {printf ("Average Days:\n\n"); for(x=0; x<=i;x++) { for(w=0;w=j;w++) { t+=array[x][w]; } avg_d=(t/j); printf("\tDay%d=%.2f\n",x,avg_d); } } if (z=2) {printf ("Average Week:\n\n"); {for(w=0;w=j;w++) { for(x=0; x<=i;x++) { f+=array[x][w]; } avg_w=(f/7); printf ("\tWeek%d=%.2f",w,avg_w); } } } }



LinkBack URL
About LinkBacks


