Question: write a C program, grade.c, which includes a function, calculateAverage() , that can calculate the average of an arbitrary number of test scores. your program

write a C program, grade.c, which includes a function,

calculateAverage(), that can calculate the average of an arbitrary number of test scores.

your program will not know in advance how many test scores will be entered into your function

so you will need to use a sentinel value (-1) to terminate the while loop used to collect the test scores.

the test scores are integers in the range 0 to 100 and the test score average should be output to two decimal places.

be sure that the user prompts and grades input into the program are displayed in the output file.

provided below is the main() function that I would like you to use for your program:

int main (void){

int I;

fopen_s(&fp, "csis.txt", "w");

for (i = 1; i <= 4; ++i) {

calculateAverage();

}

fclose(fp);

return 0;

}

please do not modify the main() function. it should appear as the first function in the program.

Be sure to use function prototypes for each of the functions that are used in your program.

Note that the first for loop invokes the calculateAverage() function four times.

Each time the calculateAverage() function is invoked, a different set of test grades will be entered.

Please be sure to use the data shown below.

First: 78, 93, 45, 88, 89, -1

second: 87, 68, 100, -1

third: 84, 86, 90, 86, 96, 68, 82, -1

fourth: -1

Be sure that your code does not attempt to divide by zero for the fourth run of the program.

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 Databases Questions!