fork 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 Students
  13. for (students=0; [students]; students++)
  14. {
  15. // reset Sum to 0
  16. Sum =0.0;
  17. printf("Enter Student Name \n");
  18. scanf("%s", StudentName);
  19. // Nested Loop for Exams
  20. for (exams=0; exams < 3; exams++)
  21. {
  22. printf ("Enter exam grade: \n");
  23. scanf("%f", &ExamValue);
  24. Sum += ExamValue;
  25. }
  26. Avg = Sum/3.0;
  27. printf( "Average for %s is %f\n",StudentName,Avg);
  28. }
  29. return 0;
  30. }
  31.  
  32.  
  33.  
  34.  
  35.  
  36. }
  37.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Jody
100.00
65.00
75.00
Miesha
100.00
100.00
95.00
Thomas
65.00
78.00
95.00
Professor
35.00
25.00
90.00
Chandler
100.00
100.00
100.00
Kaydence
100.00
90.00
96.00
Camisha
100.00
60.00
80.00
compilation info
prog.c: In function 'main':
prog.c:11:7: error: expected identifier or '(' before '[' token
   int [students],exams;
       ^
prog.c:13:8: error: 'students' undeclared (first use in this function)
   for (students=0; [students]; students++) 
        ^
prog.c:13:8: note: each undeclared identifier is reported only once for each function it appears in
prog.c:13:20: error: expected expression before '[' token
   for (students=0; [students]; students++) 
                    ^
prog.c:20:10: error: 'exams' undeclared (first use in this function)
     for (exams=0; exams < 3; exams++)
          ^
prog.c: At top level:
prog.c:36:1: error: expected identifier or '(' before '}' token
 }
 ^
stdout
Standard output is empty