fork download
  1. // C code
  2. // This program will calculate the average of 3 exams for X students.
  3. // Developer: Faculty CMIS102
  4. // Date: Dec 4, 2016
  5. #include <stdio.h>
  6. int main ()
  7. {
  8. /* variable definition: */
  9. 'this is a static string' StudentName[100];
  10. float ExamValue, Sum, Avg;
  11. int students,exams, i;
  12. // Loop through X number of Students
  13. /* Initialize */
  14. i=0;
  15.  
  16. printf("How many students do you want grade for\n");
  17. scanf("%d", &i);
  18.  
  19.  
  20.  
  21.  
  22. for (students=0; students <i ; students++)
  23. {
  24. // reset Sum to 0
  25. Sum =0.0;
  26. printf("Enter Student Name \n");
  27. scanf("%s", StudentName);
  28. // Nested Loop for Exams
  29. for (exams=0; exams < 3; exams++)
  30. {
  31. printf ("Enter exam grade: \n");
  32. scanf("%f", &ExamValue);
  33. Sum += ExamValue;
  34. }
  35. Avg = Sum/3.0;
  36. printf( "Average for %s is %f\n",StudentName,Avg);
  37. }
  38. return 0;
  39. }
  40.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:9:3: warning: character constant too long for its type
   'this is a static string' StudentName[100];
   ^
prog.c:9:3: warning: statement with no effect [-Wunused-value]
prog.c:9:29: error: expected ';' before 'StudentName'
   'this is a static string' StudentName[100];
                             ^
prog.c:27:18: error: 'StudentName' undeclared (first use in this function)
      scanf("%s", StudentName);   
                  ^
prog.c:27:18: note: each undeclared identifier is reported only once for each function it appears in
stdout
Standard output is empty