fork download
  1. #include
  2. int main ()
  3. {
  4. /* variable definition: */
  5. int count, value, sum;
  6. double avg;
  7. /* Initialize */
  8. count = 0;
  9. sum = 0;
  10. avg = 0.0;
  11. // Loop through to input values
  12. while (count < 10)
  13. {
  14. printf(“Enter a positive integer\n”);
  15. scanf (%d, &value);
  16. if (value >= 0 {
  17. sum = sum + value
  18. count = count + 1;
  19. }
  20. else {
  21. printf (“Value must be positive\n”);
  22. }
  23. }
  24. // Calculate avg. Need to type cast since two integers will yield an integers
  25. avg = (double) sum/count;
  26. printf(“average is %1f\n “ , avg );
  27. return 0;
  28. }
  29.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:10: error: #include expects "FILENAME" or <FILENAME>
 #include
          ^
prog.c: In function ‘main’:
prog.c:14:3: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
   printf(“Enter a positive integer\n”);
   ^~~~~~
prog.c:14:3: warning: incompatible implicit declaration of built-in function ‘printf’
prog.c:14:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
prog.c:14:10: error: stray ‘\342’ in program
   printf(“Enter a positive integer\n”);
          ^
prog.c:14:11: error: stray ‘\200’ in program
   printf(“Enter a positive integer\n”);
           ^
prog.c:14:12: error: stray ‘\234’ in program
   printf(“Enter a positive integer\n”);
            ^
prog.c:14:13: error: ‘Enter’ undeclared (first use in this function)
   printf(“Enter a positive integer\n”);
             ^~~~~
prog.c:14:13: note: each undeclared identifier is reported only once for each function it appears in
prog.c:14:19: error: expected ‘)’ before ‘a’
   printf(“Enter a positive integer\n”);
                   ^
prog.c:14:37: error: stray ‘\’ in program
   printf(“Enter a positive integer\n”);
                                     ^
prog.c:14:39: error: stray ‘\342’ in program
   printf(“Enter a positive integer\n”);
                                       ^
prog.c:14:40: error: stray ‘\200’ in program
   printf(“Enter a positive integer\n”);
                                        ^
prog.c:14:41: error: stray ‘\235’ in program
   printf(“Enter a positive integer\n”);
                                         ^
prog.c:15:1: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
 scanf (“%d, &value);
 ^~~~~
prog.c:15:1: warning: incompatible implicit declaration of built-in function ‘scanf’
prog.c:15:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
prog.c:15:8: error: stray ‘\342’ in program
 scanf (“%d, &value);
        ^
prog.c:15:9: error: stray ‘\200’ in program
 scanf (“%d, &value);
         ^
prog.c:15:10: error: stray ‘\234’ in program
 scanf (“%d, &value);
          ^
prog.c:15:11: error: expected expression before ‘%’ token
 scanf (“%d, &value);
           ^
prog.c:16:16: error: expected ‘)’ before ‘{’ token
 if (value >= 0 {
                ^
prog.c:21:14: error: stray ‘\342’ in program
      printf (“Value must be positive\n”);
              ^
prog.c:21:15: error: stray ‘\200’ in program
      printf (“Value must be positive\n”);
               ^
prog.c:21:16: error: stray ‘\234’ in program
      printf (“Value must be positive\n”);
                ^
prog.c:21:39: error: stray ‘\’ in program
      printf (“Value must be positive\n”);
                                       ^
prog.c:21:41: error: stray ‘\342’ in program
      printf (“Value must be positive\n”);
                                         ^
prog.c:21:42: error: stray ‘\200’ in program
      printf (“Value must be positive\n”);
                                          ^
prog.c:21:43: error: stray ‘\235’ in program
      printf (“Value must be positive\n”);
                                           ^
prog.c:23:1: error: expected expression before ‘}’ token
 }
 ^
prog.c:26:1: warning: incompatible implicit declaration of built-in function ‘printf’
 printf(“average is %1f\n “ , avg );
 ^~~~~~
prog.c:26:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
prog.c:26:8: error: stray ‘\342’ in program
 printf(“average is %1f\n “ , avg );
        ^
prog.c:26:9: error: stray ‘\200’ in program
 printf(“average is %1f\n “ , avg );
         ^
prog.c:26:10: error: stray ‘\234’ in program
 printf(“average is %1f\n “ , avg );
          ^
prog.c:26:11: error: ‘average’ undeclared (first use in this function)
 printf(“average is %1f\n “ , avg );
           ^~~~~~~
prog.c:26:19: error: expected ‘)’ before ‘is’
 printf(“average is %1f\n “ , avg );
                   ^~
prog.c:26:23: error: invalid suffix "f" on integer constant
 printf(“average is %1f\n “ , avg );
                       ^~
prog.c:26:25: error: stray ‘\’ in program
 printf(“average is %1f\n “ , avg );
                         ^
prog.c:26:28: error: stray ‘\342’ in program
 printf(“average is %1f\n “ , avg );
                            ^
prog.c:26:29: error: stray ‘\200’ in program
 printf(“average is %1f\n “ , avg );
                             ^
prog.c:26:30: error: stray ‘\234’ in program
 printf(“average is %1f\n “ , avg );
                              ^
prog.c:6:8: warning: variable ‘avg’ set but not used [-Wunused-but-set-variable]
 double avg;
        ^~~
stdout
Standard output is empty