I want to be able to process multiple students, but my program ends after processing the first student. How do I tell the program to re-run the "more students (Y or N)?" code and keep doing so until there are no more students left and the user enters "N"?Code:#include <stdio.h> #include <stdlib.h> void welcome(); void processOneStudent(); void returnStudentData(int* studentId, int* class, int* cumulativeHours, float* cumulativeGPA); void reportSummary(int* numStudents, int* numInGoodStanding); int main () { int numStudents = 0, numInGoodStanding = 0; char moreStudents; welcome(); printf("more students (Y or N)? "); scanf("%c", &moreStudents); if ((moreStudents == 'Y')||(moreStudents == 'y')) { numStudents = numStudents + 1; processOneStudent(); } if ((moreStudents == 'N')||(moreStudents == 'n')) { reportSummary(&numStudents, &numInGoodStanding); } return (0); } void welcome() { printf("*************************************************\n"); printf("* Welcome to the Academic Standing System *\n"); printf("* Developed by Hugh Saddler *\n"); printf("*************************************************\n\n"); } void processOneStudent() { int studentId, class, cumulativeHours, credit, hour; float cumulativeGPA; printf("Enter student id, class, cum. hours, cum. GPA: "); scanf("%d%d%d%f", &studentId, &class, &cumulativeHours, &cumulativeGPA); do { printf("Hours and grade (0 0 to end)? "); scanf("%d%d", &credit, &hour); cumulativeHours = cumulativeHours + hour; } while ((credit > 0)||(hour > 0)); if((credit == 0)||(hour == 0)) { returnStudentData(&studentId, &class, &cumulativeHours, &cumulativeGPA); } } void returnStudentData(int* studentId, int* class, int* cumulativeHours, float* cumulativeGPA) { printf("\n"); printf("Student Id: %d\n", *studentId); printf("Class: %d\n", *class); printf("New cumulative hours: %d\n", *cumulativeHours); printf("New cumulative GPA: %.2f\n", *cumulativeGPA); } void reportSummary(int* numStudents, int* numInGoodStanding) { printf("\n"); printf("Number of students = %d\n", *numStudents); printf("Number in good standing = %d\n", *numInGoodStanding); printf("\n"); printf("Thank you for using the Academic Standing System. Bye bye!\n"); }
Note: I haven't programmed to output the correct GPA, the number of students processed, and the number of students in good standing, so they may appear to be incorrect while reviewing my code. Right now, I just need help with getting the program to process multiple students instead of exiting unexpectedly. Thanks!


