Question: Hello i am having trouble getting my c program code to work, iam taking cmis 102. I need to be able to input any amount

Hello i am having trouble getting my c program code to work, iam taking cmis 102. I need to be able to input any amount of students into the code. I got as far as entering how many but i am not sure how to break the loop once i enter how many students i want. below is the code lets me keep entering students and grades but i need help on how to stop it once i am done. Thanks!

// C code

// This program will calculate the average

// of 3 exams for 5 students.

// Developer: Faculty CMIS102

// Date: Jan 31, XXXX

#include stdio.h

int main(void) {

// variable declarations:

char name [100];

float sum, grade, average;

int students, exams, n;

// loop through 5 students

for (students = 1; 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 ", name, average);

} // end for each student

printf("... Bye ... ");

return 0;

} // end main

<>

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