fork download
  1. // C code
  2. // This program will calculate the sum of 10 positive integers.
  3. // Developer: Faculty CMIS102
  4. // Date: Jan 31, XXXX
  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.0;
  15. // Loop through to input values
  16. while (count < 20)
  17. {
  18. printf("Enter a positive Integer\n");
  19. scanf("%d", &value);
  20. if (value >= 0) {
  21. sum = sum + value;
  22. count = count + 1;
  23. }
  24. else {
  25. printf("Value must be positive\n");
  26. }
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:27:1: error: expected declaration or statement at end of input
 }
 ^
prog.c:10:8: warning: variable ‘avg’ set but not used [-Wunused-but-set-variable]
 double avg;
        ^~~
stdout
Standard output is empty