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 */count = 0;
  12.  
  13. sum = 0;
  14. avg = 0.0;
  15.  
  16. // Loop through to input values
  17.  
  18. while (count < 20){
  19. printf("Enter a positive Integer\n");
  20. scanf("%d", &value);
  21. if (value >= 0) {
  22. sum = sum + value;
  23. count = count + 1;
  24. }
  25. else {
  26. printf("Value must be positive\n");
  27.  
  28. }
  29.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:28:1: error: expected declaration or statement at end of input
 }
 ^
prog.c:28: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