fork download
  1. // C code
  2. // This program will calculate the average of 3 exams for students.
  3. // Developer: ERIKA HOTTINGER CMIS102
  4. // Date: Oct 22, 2017
  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.  
  13. scanf("%s", StudentName);
  14. // Loop through Students
  15. for (students=0; students < %s ; students++)
  16. {
  17. // reset Sum to 0
  18. Sum =0.0;
  19. printf("Enter Student Name: \n\n");
  20.  
  21. // Nested Loop for Exams
  22. for (exams=0; exams < 3; exams++)
  23. {
  24. printf ("Enter exam grade: \n");
  25. scanf("%f", &ExamValue);
  26. Sum += ExamValue;
  27. }
  28. Avg = Sum/3.0;
  29. printf( "Average for %s is %f\n\n\n\n",StudentName,Avg);
  30. }
  31. return 0;
  32. }
  33.  
  34.  
Compilation error #stdin compilation error #stdout 0s 10304KB
stdin
erike
10
10
10
mina
2
3
8
compilation info
prog.c: In function ‘main’:
prog.c:15:31: error: expected expression before ‘%’ token
   for (students=0; students < %s ; students++)
                               ^
stdout
Standard output is empty