I have a list of grades for 3 students, that lists 2 of their subjects, and their performances on 8 tests (4 per subject). So the array looks kinda like [student][subject][testgrades]. My code so far looks like this
[CODE]
#include <stdio.h>
float allgradeavg(float grades[][2][4]);
int main(void)
{
float grades[3][2][4]=
{
{
{75,63,98,74},
{90,91,87,80}
},
{
{99,98,91,93},
{75,76,78,70}
},
{
{78,76,74,70},
{75,76,72,75}
},
};
allgradeavg(grades);
return 0;
}
float allgradeavg(float grades[][2][4])
{
float total=0;
int i,j, k, numberofgrades=0;
for(i=0;i<=2;i++)
for(j=0;j<=1;j++)
for(k=0;k<=3;k++)
{
total+=grades[i][j][k];
}
printf("%f", total/24);
return total/24;
}
[CODE]
The above function is used to find the average of all scores. The second problem is finding the average grade for each subject (passing two dimensional arrays to the function) I have not yet made the function. How can I break down a three-dimensional array into a two dimensional ones, and which dimensions do I even use? I am very lost, any help is greatly appreciated.