Question
This is a C program. If you run the code, it will show you a 2D array of the test scores of 3 students and
This is a C program. If you run the code, it will show you a 2D array of the test scores of 3 students and their averages. The row of "Student no 4" shows just the average of every test. What I want you to do is add the average for all the class (excluding Student no 4 which is the average row of every test). Please make sure to complete and modify according to what I wrote, and not create a total remake of the program. I hope your solution is clear, simple, and concised.
Thank you and I appreciate your help.
#include
#include
#define CLS system("cls")
#define PAUSE system("pause")
#define ROWS 10000
#define COLS 5 // modified it from 4 to 5
void displayArray(float grades[][COLS], int c) {
int i, j;
CLS;
// to update sums of each test and for each student
for(i=0;i { for(j=0;j { grades[i][COLS-1] += grades[i][j]; grades[c-1][j] +=grades[i][j]; } } // to update each student's sum to average for(i=0;i { grades[i][COLS-1] = grades[i][COLS-1]/(COLS-1)*1.0; grades[c-1][COLS-1] += grades[i][COLS-1]; } // to update each exam's average for(i=0;i { grades[c-1][i] = grades[c-1][i]/(c-1)*1.0; } printf("-----\t---\t---\t---\t---\t----- "); printf("StdNo\tEX1\tEx2\tEx3\tEx4\t|Avg| "); printf("-----\t---\t---\t---\t---\t----- "); for (i = 0; i < c; i++) { printf("%i\t", i+1); for (j = 0; j < COLS; j++) printf("%.1f\t", grades[i][j]); printf(" "); } // end outer loop PAUSE; } // end displayArray int main() { int counter = 0; // stores the effective size float grades[ROWS][COLS] = { {60,70,80,85}, {30,86,91,98}, {89,93,83,91}, {0,0,0,0}}; counter = 3; displayArray(grades, counter+1); //no pass for reference * PAUSE; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started