Code a program in c that will calculate the average of 3


Code a program in C that will calculate the average of 3 exams for an undetermined # of students.

I have been given a base code that I must modify using a sentinel that will stop the loop counter. I can not seem to code the loop to accept the break.

Base Code:
#include
int main ()
{
/* variable definition: */
char StudentName[100];
float ExamValue, Sum, Avg;
int students,exams;
// Loop through 5 Students
for (students=0; students <5 ; students++)
{
// reset Sum to 0
Sum =0.0;
printf("Enter Student Name n");
scanf("%s", StudentName);
// Nested Loop for Exams
for (exams=0; exams < 3; exams++)
{
printf ("Enter exam grade: n");
scanf("%f", &ExamValue);
Sum += ExamValue;
}
Avg = Sum/3.0;
printf( "Average for %s is %fn",StudentName,Avg);
}
return 0;
}

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Code a program in c that will calculate the average of 3
Reference No:- TGS01488601

Now Priced at $10 (50% Discount)

Recommended (99%)

Rated (4.3/5)