Question: Having trouble with my code; #include #define MAX _ STUDENTS 5 0 int main ( ) { int numStudents, id [ MAX _ STUDENTS ]

Having trouble with my code; #include
#define MAX_STUDENTS 50
int main(){
int numStudents, id[MAX_STUDENTS];
float midterm[MAX_STUDENTS], final [MAX_STUDENTS], weightedAvg[MAX_STUDENTS], deviation[MAX_STUDENTS], totalWeightAvg =0, avgWeightedAvg;
// Get the number of students from the teacher
printf("Enter the number of students in the class (max 50): ");
scanf("%d", &numStudents);
// Input student data
for ( i =0; i numStudents; i++)
{
printf("
Enter details for Student %d:
", i +1);
printf("ID: ");
scanf("%d", &id[i]);
printf("Midterm Grade: ");
scanf("%f", &midterm[i]);
printf("Final Grade: ");
scanf("%f", &final[i]);
// Calculate weighted average for each student
weightedAvg[i]=0.45* midterm[i]+0.55* final[i];
totalWeightedAvg += weightedAvg[i];
}
// Calculate average of all weighted averages
avgWeightedAvg = totalWeightedAvg / numStudents;
// Calculate deviation for each student
for (int i =0; i numStudents; i++){
deviation[i]= weightedAvg[i]- avgWeightedAvg;
}
// Display results in a table
printf("
Class Average Weighted Average: %.2f
", avgWeightedAvg);
printf("---------------------------------------------------------
");
printf("| ID\t| Midterm\t| Final\t| Weighted Avg\t| Deviation\t|
");
printf("---------------------------------------------------------
");
for (int i =0; i numStudents; i++){
printf("|%d\t|%.2f\t|%.2f\t|%.2f\t\t|%.2f\t\t|
", id[i], midterm[i], final[i], weightedAvg[i], deviation[i]);
}
printf("---------------------------------------------------------
");
return 0;
}
Having trouble with my code; #include #define MAX

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!