fork download
  1. #include <stdio.h>
  2.  
  3. int main (int argc, char** argv)
  4. {
  5. int i;
  6. int count;
  7. double total;
  8. double val;
  9. double average;
  10.  
  11. /* prompt the user for input */
  12. printf ("Enter in a list of numbers followed by the terminal value of -999\n");
  13.  
  14. /* loop until the user enters -999 */
  15. scanf ("%d", &val);
  16. while (val != -999)
  17. {
  18. total = total + val;
  19. count++;
  20. scanf("%d", &val);
  21. }
  22.  
  23. /* calculate the average of the values read in */
  24. average = total / count;
  25.  
  26. /* display the results */
  27. printf ("For the list of %d numbers with a total of %d\n", count, total);
  28. printf (" the average is: %15.5f\n", average);
  29.  
  30. return 0;
  31. }
Time limit exceeded #stdin #stdout 5s 2172KB
stdin
Standard input is empty
stdout
Standard output is empty