Ok I have a program that has a 2 dimensional array in it. It compiles but I cant seem to get the right value in the final row of the array. It keeps coming out to 0 when its suppose to be an average and I cant seem to figure out how to fix it. Any advice would be appreciated.
void funct(int sum[5],int array[6][5],int courses,int grade);
int main(){
int grade,courses,i=0, array[6][5],sum[5];
cout << "Imput how many grades and how many courses your going to imput" << endl;
cin >> grade >> courses;
while(i < courses){
cout << "Enter your grades for course "<< i+1 << endl;
for(int t = 0; t < grade; t++){
cin >> array[t][i];
sum[i] = array[t][i] + sum[i];
}
i++;}
funct(sum,array,courses,grade);
cout <<"the following are your grades, the final number is your average for that course" << endl;
for(int i = 0; i < courses; i++){
cout << "course " << i+1 << endl;
for(int t=0; t <= grade; t++){
cout << array[t][i] << ",";
}
cout << endl;
}}
void funct(int sum[5],int array[6][5],int courses,int grade){
int i=0,x;
while ( i < courses){
array[grade+1][i] = sum[i]/courses;
i++;
}}