#include using namespace std; // Amount of students #define ROW 2 // Amount of grades per subject #define COL 3 #define SIZE_ARRAY(array) (sizeof(array)/sizeof(array[0])) #define SIZE2D_ARRAY(array) (sizeof(array[0])/sizeof(array[0][0])) //proto types void sortRow(int list[][COL],int r,int c); void createStudents(string *s, int r); void enterGrades(string *s,int m[][COL], int h[][COL],int e[][COL],int r,int c); void gradesLowHigh(string *s,int m[][COL], int h[][COL], int e[][COL],int r,int c); void listGradesDescendingOrder(string *s, int m[][COL],int h[][COL],int e[][COL],int r,int c); int main(){ string students[ROW]; /* 2D arrays **/ int math[ROW][COL]; int history[ROW][COL]; int english[ROW][COL]; int r=0,c=0,i=0; //string name; createStudents(students,ROW); enterGrades(students,math, history,english,ROW,COL); /* Just 3 different ways of passing size of arrays **/ //use of macro. helps insure proper size //incase values have been changed elsewhere sortRow(math,SIZE_ARRAY(math),SIZE2D_ARRAY(math)); //getting sizeof just before pasing the values r = sizeof(history)/sizeof(history[0]); c = sizeof(history[0])/sizeof(history[0][0]); sortRow(history,r,c); // USING DEFINE VALUES sortRow(english,ROW,COL); gradesLowHigh(students,math,history,english, ROW,COL); listGradesDescendingOrder(students,math, history,english,ROW,COL); double msum=0,hsum=0,esum=0; double count=0; double maverage,haverage,eaverage,average; for(int i=0;i>m[i][g]; cout<<"History \n"; for(int p=0;p>h[i][p]; cout<<"English \n"; for(int k=0;k>e[i][k]; } cout<<"\n\n"; } void gradesLowHigh(string *s,int m[][COL], int h[][COL],int e[][COL],int r,int c) { int ck=0; for(int i=0;i list[i][k+1]){ if(list[i][k] < list[i][k+1]){ //swap ellrment swap(list[i][k],list[i][k+1]); } } } } }