fork download
  1. // This program will calculate the sum of 10 positive integers.
  2.  
  3. // Developer: Faculty CMIS102
  4.  
  5. // Date: Jan 31, XXXX
  6.  
  7. #include <stdio.h>
  8.  
  9. int main ()
  10.  
  11. {
  12.  
  13. /* variable definition: */
  14.  
  15. int count, value, sum;
  16. double avg;
  17.  
  18. /* Initialize */
  19.  
  20. count = 0;
  21.  
  22. sum = 0;
  23. avg = 0.0;
  24.  
  25.  
  26.  
  27. // Calculate avg. Need to type cast since two integers will yield an integer
  28.  
  29. avg = (double) sum/count;
  30.  
  31. printf("average is %lf\n " , avg );
  32.  
  33. return 0;
  34.  
  35. }
Success #stdin #stdout 0s 9424KB
stdin
2
3
2
1
2
3
4
3
2
2
stdout
average is -nan