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 you modify this code to allow the user to enter a weight for each grade? #include int main(void) { // variable declarations: char name[100]; float sum, grade, average; int students, exams, numvalues, numGrades; //set number “n” of students printf(“How many students are you finding the average for?:\n”);

How could you modify this code to allow the user to enter a weight for each grade?

#include <stdio.h>

int main(void) {

// variable declarations:

char name[100];

float sum, grade, average;

int students, exams, numvalues, numGrades;

//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++) {

// read number of grades

printf(“\nEnter the number of grades: “);

scanf(“%d”, &numGrades);

// prompt for number of grades that was entered

printf(“Enter %d grades and student name: “, numGrades);

sum = 0;

for (exams = 0; exams < numGrades; exams++) {

// float uses %f, double uses %lf

scanf(“%f”, &grade);

sum = sum + grade;

} // end for each exam

average = sum / numGrades;

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"