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", 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
Get step-by-step solutions from verified subject matter experts
