Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Homework 10 Design a program in C intended to manage the grades in a class consi

ID: 3832976 • Letter: H

Question

Homework 10 Design a program in C intended to manage the grades in a class consisting of m students and n quizzes of equal weighting given during the course of a semester. The program is to do the following in the indicated sequence when it is executed Ask the user to type on the keyboard the number of students "m" taking a course and the number of quizzes "n" in the course, with m representing the number of rows and n representing the number of columns in a two-dimensional array glm][n] called grades whose elements are inputted as floating-point numbers Ask the user to type on the keyboard the values of all the elements of the array glm][n], with each quiz grade being out of 10 points Display on the console the inputted m x n array element values Generate and display on the console the elements of a one-dimensional array agpqInl where each element of this array agpgln] represents the average grade per quiz (agpq) in each of the n quizzes Generate and display on the console the elements of a one-dimensional array agpsIm where each element of this array agpslm] represents the average grade per student (agps) over the entire semester for each of the m students Program Requirements: Your program is to employ the switch" command together with a choice varible so that, when a value of 1 is chosen for choice, the program will compute and output the one-dimenstional agpqIn] array, and, when a value of 2 is chosen for choice, the program will compute and output the other one-dimensional array namely, agps[m] ii) The inputting the elements of the grades array glm][n] is to be done within the main" function before entering a value for the choice variable iii) When a value of 1 is entered for the choice variable, the main function will call upon the prototype function called ayGradePerQuiz which will compute and then output the n] array without any return to the main function iv) When a value of 2 is entered for the choice variable, the main function will call upon the prototype function called awa radePerstudent which will compute and then output the mal array without any return to the main function v) The three prototype functions, namely, main ayGradePerQuiz and axGradePerStudent, are to be sequenced in their placement in your program as follows main GradePerQuiz ayGradePerStudent, NOTE: Use the following input data when performing your sample output gl5003 {10,8,72,19, 10,5, 4,7,9), 8,10,9 3,10, of quizzes of students

Explanation / Answer

#include <stdio.h>

/*global variable*/
int m, n, g[100][100];

/*function prototype declaration*/
void avGradePerQuiz();
void avGradePerStudent();

int main(){

   int i, j, choice;

   /*get user input*/
   printf("Enter no of students: ");
   scanf("%d", &m);
   printf("Type no of quizzes:");
   scanf("%d", &n);

   /*filling grade matrix from user*/
   printf("Enter the values of the elements of the matrix: ");
   for(i = 0; i < m; i++){
       for(j = 0; j < n; j++){
           scanf("%d", &g[i][j]);
       }
   }

   /*printing the matrix into the console*/
   printf("these are the values provided by user ");
   for(i = 0; i < m; i++){
       for(j = 0; j < n; j++){
           printf("%d ", g[i][j]);
       }
       printf(" ");
   }

   /*get user choice*/
   printf("Enter your choice please 1 : to compute avg grade per quiz 2 : to compute avg grade per student ");
   scanf("%d", &choice);

   switch(choice){
       case 1:
           /*call avGradePerQuiz() function*/
           printf("Avg grade per quiz: ");
           avGradePerQuiz();
           break;
       case 2:
           /*call avGradePerStudent()*/
           printf("Avg grade per student: ");
           avGradePerStudent();
           break;
       default:
           printf("not a valid choice ");
   }

   return 0;
}

void avGradePerQuiz(){
   /*compute avg grade per quiz of all student and output them*/
   double avgGrade = 0, gradeSum = 0;
   double agpq[100];
   int i, j;

   /*computing average grade per quiz*/
   for(i = 0; i < n; i++){
       for(j = 0; j < m; j++){
           gradeSum += g[j][i];
       }
       avgGrade = gradeSum/m;
       /*storing result in agpq*/
       agpq[i] = avgGrade;
       gradeSum = 0;
   }

   /*display agpq*/
   for(i = 0; i < n; i++){
       printf("%lf ", agpq[i]);
   }
   printf(" ");

}

void avGradePerStudent(){
   /*compute avg grade per student*/
   double avgGrade = 0, gradeSum = 0;
   double agps[100];
   int i, j;

   /*computing average grade per student*/
   for(i = 0; i < m; i++){
       for(j = 0; j < n; j++){
           gradeSum += g[i][j];
       }
       avgGrade = gradeSum/n;
       /*storing result in agpq*/
       agps[i] = avgGrade;
       gradeSum = 0;
   }

   /*display agps*/
   for(i = 0; i < m; i++){
       printf("%lf ", agps[i]);
   }
   printf(" ");

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote