two dimensional array

Will somebody help me coding this program

Based on given table, write a program using two-dimensional array that will compute for the average grade of the three students. Afterwards, output the content of the table and identify the highest and the lowest grade of all the entries in the table.
Sample output: The table representation of the two-dimensional array is:
[0] [1] [2] [3]
Student[0] 77 68 86 73
Student[1] 96 87 89 78
Student[2] 70 90 86 81

The average grade for Student[0]: 76.00
The average grade for Student[1]: 87.50
The average grade for Student[2]: 81.75
The highest grade among the table entry is: 96
The lowest grade among the table entry is: 68
Last edited on
For each row ( Student ) evaluate the average ( sum / 4. )
While you do this you can keep a record of the maximum and minimum grades you find
#include <iostream>
using namespace std;

//function declaration
int ave(double ave0,double ave1,double ave2)
{
int a,total=0;

for(a=0;a<4;a++)
ave0 = (double) total/4;
return ave0;

for(a=0;a<4;a++)
ave1 = (double) total/4;
return ave1;

for(a=0;a<4;a++)
ave2 = (double) total/4;
return ave2;

}

int main()
{

int average0,average1,average2,highest,lowest;

cout<<endl;
cout<<"A given table below is the list of grades of three students in a class:"<<endl<<endl;

//table for grades of three students in a class
cout<<"\t\t -------------------------------"<<endl;
cout<<"\t\t|Student[0] | 77 | 68 | 86 | 73 |"<<endl;
cout<<"\t\t -------------------------------"<<endl;
cout<<"\t\t|Student[1] | 96 | 87 | 89 | 78 |"<<endl;
cout<<"\t\t -------------------------------"<<endl;
cout<<"\t\t|Student[2] | 70 | 90 | 86 | 81 |"<<endl;
cout<<"\t\t -------------------------------"<<endl<<endl<<endl;

ave(average0,average1,average2);

//output
cout<<"The average grade for Student[0]: "<<average0<<endl;
cout<<"The average grade for Student[1]: "<<average1<<endl;
cout<<"The average grade for Student[2]: "<<average2<<endl;
cout<<"The highest grade among the table entry is: "<<highest<<endl;
cout<<"The lowest grade among the table entry is: "<<lowest<<endl;

return 0;
}

This is my code. It output the wrong average but when i put the function in the main program, it ouputs the correct value. Help me fixing the error in my code plz...
Topic archived. No new replies allowed.