fork(1) download
  1. // C code
  2. // This program will calculate the average of 3 exams for 5 students.
  3. // Developer: Faculty CMIS102
  4. // Date: Jan 31, XXXX
  5. #include <stdio.h>
  6. int main ()
  7. {
  8. /* variable definition: */
  9. char StudentName[100];
  10. float ExamValue, Sum, Avg;
  11. int students,exams;
  12. // Loop through 5 Students
  13. while (students<max )
  14. for (students=1; students++)
  15. {
  16. // reset Sum to 0
  17. Sum =0.0;
  18. printf("Enter Student Name, -1 to end \n");
  19. scanf("%s", StudentName);
  20. // Nested Loop for Exams
  21. for (exams=0; exams < 3; exams++)
  22. {
  23. printf ("Enter exam grade: \n");
  24. scanf("%f", &ExamValue);
  25. Sum += ExamValue;
  26. }
  27. Avg = Sum/3.0;
  28. printf( "Average for %s is %f\n",StudentName,Avg);
  29. }
  30. return 0;
  31. }
  32.  
  33.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
John: 90.0 80.0 100.0
Jim: 80.0 70.0 90.0
Joe: 70.0 100.0 100.0
Sally: 100.0 95.0 91.0
Sam: 30.0 54.0 68.0 
-1
compilation info
prog.c: In function 'main':
prog.c:13:20: error: 'max' undeclared (first use in this function)
    while (students<max )
                    ^
prog.c:13:20: note: each undeclared identifier is reported only once for each function it appears in
prog.c:14:30: error: expected ';' before ')' token
   for (students=1; students++) 
                              ^
stdout
Standard output is empty