fork download
  1. // c code
  2. // This program will calculate the average of positive integers.
  3. // Developer: Mirabel
  4. // Date: 06/21/2017
  5. #include <stdio.h>
  6. int main ()
  7. {
  8. /* variable definition: */
  9. int count, value, sum;
  10. double avg;
  11. /* Initialize */
  12. count = 0;
  13. sum = 0;
  14. avg = 0;
  15. // Loop through to input values
  16. while (ount < input);
  17. {
  18. printf("Enter a positive Intergar\n");
  19. scanf("d%", &value);
  20. if (value >= 0)
  21. {
  22. sum = sum + value;
  23. count = cont +1;
  24. }
  25. else{
  26. printf("value must be positive\n");
  27. }
  28. }
  29. // Calculate avg. Need to type cast since two intergers will yield an inter
  30. avg = (double) sum/count;
  31. printf("average is %1f\n" , avg);
  32. return 0;
  33. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
10
20
30
compilation info
prog.c: In function ‘main’:
prog.c:16:9: error: ‘ount’ undeclared (first use in this function)
  while (ount < input);
         ^~~~
prog.c:16:9: note: each undeclared identifier is reported only once for each function it appears in
prog.c:16:16: error: ‘input’ undeclared (first use in this function)
  while (ount < input);
                ^~~~~
prog.c:19:14: warning: spurious trailing ‘%’ in format [-Wformat=]
      scanf("d%", &value);
              ^
prog.c:19:12: warning: too many arguments for format [-Wformat-extra-args]
      scanf("d%", &value);
            ^~~~
prog.c:23:14: error: ‘cont’ undeclared (first use in this function)
      count = cont +1;
              ^~~~
stdout
Standard output is empty