0

Good evening;

I am having a final exam next week and I'm having an issue with this program.

the program should user receive from the user 6 marks for each one of four students and then compute the average and finally show the index of the student who has the highest average.(using a dynamic two Dimensional array).

Now, I have no errors at all but, the programme does not show the correct index .In fact, it shows a constant number no matter what numbers I enter.

I appreciate the help.

```
#include<iostream>
using namespace std;
int main(){
double **marks2d;
double stud_row=4,Quiz_Col=6;
double sumup=0;double *avg=new double[stud_row];
marks2d=new double *[stud_row];
for(int i=0;i<stud_row;i++)
marks2d[i]=new double[Quiz_Col];
for(int y=0;y<stud_row;y++)
{cout<<"Enter 6 marks for student number#"<<y+1<<endl;
for(int x=0;x<Quiz_Col;x++)
{cin>>marks2d[y][x];
sumup+=marks2d[y][x];}
avg[y]=sumup/Quiz_Col;}
int maxindex=0;
double max=avg[0];
for(int t=0;t<stud_row;t++)
{if (avg[t]>max){maxindex=t;max=avg[t];}}
cout<<"\n\n\n\n\n\nthe student with the highest average is stud number:"<<maxindex+1<<"\n\n\n\n";return 0;}
```