fork download
  1. #include <stdio.h>
  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", value);
  15. scanf("%d", &value);
  16. printf("%d", value)
  17. if (value >= 0) {
  18. sum = sum + value;
  19. count = count + 1;
  20. }
  21. else {
  22. printf("Value must be positive\n");
  23. }
  24. }
  25. // Calculate avg. Need to type cast since two integers will yield an integer
  26. avg = (double) sum/count;
  27. printf("average is %lf\n " , avg );
  28. return 0;
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1
1
1
0
1
2
0
1
3
2
compilation info
prog.c: In function ‘main’:
prog.c:14:9: warning: too many arguments for format [-Wformat-extra-args]
  printf("Enter a positive Integer \n", value);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.c:17:2: error: expected ‘;’ before ‘if’
  if (value >= 0) {
  ^~
stdout
Standard output is empty