This assignment is a grade calculator(using c not c++). A portion of the code is
ID: 3791062 • Letter: T
Question
This assignment is a grade calculator(using c not c++).
A portion of the code is included in the nested loop document. It will need to be modified of course to include the grade variable and weight array variable. Also, change the marks array indices to 4 students and 5 marks so as to make it easier to input the info.
The weight array should be described as follows: weight[] = {1, 1, 0.8333, 0.75, 0.6667}
The output should look like:
Student #1's final mark is 74.62%
Student #2's final mark is 68.46%
Student #3's ...
START IS no j 4 yes IS no i 5 yes input marks [ji[ij i 1 j -j 1 IS no 4 END yes grade 0 no /output IS I 5 j, grade yes weight ilxmarkslil i 1 j -j 1Explanation / Answer
Here is the C code for you...
#define NUM_OF_STUDENTS 4
#define NUM_OF_MARKS 5
#include <stdio.h>
int main()
{
float weight[] = {1, 1, 0.8333, 0.75, 0.6667};
int marks[NUM_OF_STUDENTS][NUM_OF_MARKS];
for(int j = 0; j < NUM_OF_STUDENTS; j++) //For 4 students.
for(int i = 0; i < NUM_OF_MARKS; i++) //For 5 marks.
{
printf("Enter marks for Student #%d, Marks #%d: ", j+1, i+1);
scanf("%d", &marks[j][i]);
}
for(int j = 0; j < NUM_OF_STUDENTS; j++)
{
float grade = 0;
for(int i = 0; i < NUM_OF_MARKS; i++)
grade += weight[i] * marks[j][i];
printf("Student #%d's final mark is %.2f%% ", j+1, grade);
}
printf(" ");
}