Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

How could this code be modified to allow the user to enter a different amount of grades per student? For example, 1st student has 3 grades, 2nd student has 5, etc.

How could this code be modified to allow the user to enter a different

amount of grades per student? For example, 1st student has 3 grades, 2nd student has 5, etc.

#include <stdio.h>

int main(void) {
// variable declarations:
char name [100];
float sum, grade, average;
int students, exams, numvalues;

//set number “n” of students
printf(“How many students are you finding the average for?:\n”);
scanf(“%d”, &numvalues);

// loop through 5 students
for (students = 0; students < numvalues; students++) {
printf (“Enter 3 grades and student name: “);
sum = 0;
for (exams = 0; exams < 3; exams++) {
// float uses %f, double uses %lf
scanf (“%f”, &grade);
sum = sum + grade;

} // end for each exam
average = sum / 3;
scanf (“%s”, name);
printf (“Average for %s is %.2f\n”, name, average);

} // end for each student
printf(“… Bye …\n”);
return 0;
} // end main

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"