#include /* function prototypes */ void FindAve(int [][2], int, int); void main(void) { /* The simple program that finds the assignment average for asn1 and asn2 as well as the student averages of 5 students in a class, using two dimensional array with a function. Also, print the result with input data in a table */ int asn[5][2]; /* The function FindAve is called to read all Marks and compute and print the average with the marks */ FindAve(asn, 5, 2); } /****** Function Definition begins ****/ void FindAve(int asn[][2], int numrow, int numcol) { float stuaverage[5], asnaverage[2]; int r, c, asntot[2]={0,0}, stusum[5]; for (r= 0; r< numrow; r++) { stusum[r] = 0; printf("type the two asn marks for student %d \t:", r); for (c= 0; c< numcol; c++) { scanf("%d", &asn[r][c]); stusum[r] += asn[r][c]; asntot[c] += asn[r][c]; } stuaverage[r] = (float) stusum[r]/numcol; } for (c= 0; c< numcol; c++) { asnaverage[c] = (float) asntot[c]/numrow; } /* This now prints the input data and result */ printf("Assignments \t\t student average\n"); for (r= 0; r< numrow; r++) { for (c= 0; c< numcol; c++) { printf("%d \t", asn[r][c]); } printf("\t %0.2f \n", stuaverage[r]); } for (c= 0; c< numcol; c++) { printf("%0.2f \t", asnaverage[c]); } printf("\n"); }