fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int t1, t2, t3, prj, r, line = 0;
  7. float h1, h2, h3, h4;
  8.  
  9. FILE *fp = fopen("student.dat", "rt");
  10. fscanf(fp, "%d %d %d %e %e %e %e %d", t1, t2, t3, h1, h2, h3, h4, prj);
  11.  
  12. if (fp == NULL)
  13. {
  14. printf ("Error opening the file\n\n'");
  15. exit(EXIT_FAILURE);
  16. }
  17. else
  18. {
  19.  
  20. r = fscanf(fp, "%d %d %d %e %e %e %e %d", t1, t2, t3, h1, h2, h3, h4, prj);
  21. while (r != EOF)
  22. {
  23. t1 = t1/100 * 20;
  24. t2 = t2/100 * 20;
  25. t3 = t3/100 * 20;
  26. float avgH = (h1 + h2 + h3)/3;
  27. prj = prj/100*30;
  28. printf(t1 + t2 + t3 + avgH + prj);
  29. r = fscanf(fp, "%d %d %d %e %e %e %e %d", t1, t2, t3, h1, h2, h3, h4, prj);
  30.  
  31. }
  32.  
  33. }
  34.  
  35. fclose(fp);
  36.  
  37. }
  38.  
  39. return (0);
  40. }
  41.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:10:16: warning: format '%d' expects argument of type 'int *', but argument 3 has type 'int' [-Wformat=]
     fscanf(fp, "%d %d %d %e %e %e %e %d", t1, t2, t3, h1, h2, h3, h4, prj);
                ^
prog.c:10:16: warning: format '%d' expects argument of type 'int *', but argument 4 has type 'int' [-Wformat=]
prog.c:10:16: warning: format '%d' expects argument of type 'int *', but argument 5 has type 'int' [-Wformat=]
prog.c:10:16: warning: format '%e' expects argument of type 'float *', but argument 6 has type 'double' [-Wformat=]
prog.c:10:16: warning: format '%e' expects argument of type 'float *', but argument 7 has type 'double' [-Wformat=]
prog.c:10:16: warning: format '%e' expects argument of type 'float *', but argument 8 has type 'double' [-Wformat=]
prog.c:10:16: warning: format '%e' expects argument of type 'float *', but argument 9 has type 'double' [-Wformat=]
prog.c:10:16: warning: format '%d' expects argument of type 'int *', but argument 10 has type 'int' [-Wformat=]
prog.c:20:28: warning: format '%d' expects argument of type 'int *', but argument 3 has type 'int' [-Wformat=]
             r = fscanf(fp, "%d %d %d %e %e %e %e %d", t1, t2, t3, h1, h2, h3, h4, prj);
                            ^
prog.c:20:28: warning: format '%d' expects argument of type 'int *', but argument 4 has type 'int' [-Wformat=]
prog.c:20:28: warning: format '%d' expects argument of type 'int *', but argument 5 has type 'int' [-Wformat=]
prog.c:20:28: warning: format '%e' expects argument of type 'float *', but argument 6 has type 'double' [-Wformat=]
prog.c:20:28: warning: format '%e' expects argument of type 'float *', but argument 7 has type 'double' [-Wformat=]
prog.c:20:28: warning: format '%e' expects argument of type 'float *', but argument 8 has type 'double' [-Wformat=]
prog.c:20:28: warning: format '%e' expects argument of type 'float *', but argument 9 has type 'double' [-Wformat=]
prog.c:20:28: warning: format '%d' expects argument of type 'int *', but argument 10 has type 'int' [-Wformat=]
prog.c:28:24: error: incompatible type for argument 1 of 'printf'
                 printf(t1 + t2 + t3 + avgH + prj);
                        ^
In file included from prog.c:1:0:
/usr/include/stdio.h:362:12: note: expected 'const char * restrict' but argument is of type 'long double'
 extern int printf (const char *__restrict __format, ...);
            ^
prog.c:29:33: warning: format '%d' expects argument of type 'int *', but argument 3 has type 'int' [-Wformat=]
                  r = fscanf(fp, "%d %d %d %e %e %e %e %d", t1, t2, t3, h1, h2, h3, h4, prj);
                                 ^
prog.c:29:33: warning: format '%d' expects argument of type 'int *', but argument 4 has type 'int' [-Wformat=]
prog.c:29:33: warning: format '%d' expects argument of type 'int *', but argument 5 has type 'int' [-Wformat=]
prog.c:29:33: warning: format '%e' expects argument of type 'float *', but argument 6 has type 'double' [-Wformat=]
prog.c:29:33: warning: format '%e' expects argument of type 'float *', but argument 7 has type 'double' [-Wformat=]
prog.c:29:33: warning: format '%e' expects argument of type 'float *', but argument 8 has type 'double' [-Wformat=]
prog.c:29:33: warning: format '%e' expects argument of type 'float *', but argument 9 has type 'double' [-Wformat=]
prog.c:29:33: warning: format '%d' expects argument of type 'int *', but argument 10 has type 'int' [-Wformat=]
prog.c:6:29: warning: unused variable 'line' [-Wunused-variable]
     int t1, t2, t3, prj, r, line = 0;
                             ^
prog.c: At top level:
prog.c:39:5: error: expected identifier or '(' before 'return'
     return (0);
     ^
prog.c:40:2: error: expected identifier or '(' before '}' token
  }
  ^
stdout
Standard output is empty