fork download
  1. #include <stdio.h>
  2.  
  3. int main ()
  4. {
  5. /* variable definition: */
  6. int count, value, sum;
  7. double avg;
  8. /* Initialize */
  9. count = 0;
  10. sum = 0;
  11. printf("Enter a positive Integer. A negative integer will end the program.\n");
  12. scanf("%d", &value);
  13. // Loop through to input values
  14. while (value >= 0)
  15. {
  16. sum = sum + value;
  17. count = count + 1;
  18. }
  19.  
  20. // Calculate avg. Need to type cast since two integers will yield an integer
  21.  
  22. avg = (double) sum / count;
  23. printf("average is %lf\n " , avg );
  24. return 0;
  25. }
  26.  
Time limit exceeded #stdin #stdout 5s 9432KB
stdin
213
123
123
-123
923
234
stdout
Standard output is empty