I have started a C programming class just a few weeks ago and I am having a hard time learning the how to make loops with unlimited inputs. The code is originally setup to find the average grade for 5 students with three test scores each.
The code I am working with is:
#include <stdio.h>
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 %f\n",StudentName,Avg);
}
return 0;
}
I need to allow unlimited input, I have tried changing "students <5" to both "student =!" and "student
Also can anyone help me understand this line in the code?
char StudentName[100];
My course doesn't even mention it, and I can't find it online. If anyone can point me to a great source for learning C please let me know.
Thanks in advance for your help.