fork download
  1. #include <stdio.h>
  2. int main ( )
  3. {
  4.  
  5. float average; /* The average of a set of numbers */
  6. int i; /* loop index */
  7. int number; /* user entered number */
  8. float sum; /* running total of the numbers */
  9.  
  10. sum = 0; /* Very important to do this */
  11.  
  12. /* Read in all numbers and keep a running total */
  13. for (i=0; i < 5; ++i)
  14. {
  15. printf ("Enter an integer value: ");
  16. scanf ("%i", &number);
  17.  
  18. sum += number; /* running total */
  19. }
  20.  
  21. average = sum / 5; /* get the average */
  22.  
  23. /* WHAT DO I DO NOW? */
  24.  
  25. return (0);
  26. }
Success #stdin #stdout 0.01s 5228KB
stdin
6
12
18
24
32
stdout
Enter an integer value: Enter an integer value: Enter an integer value: Enter an integer value: Enter an integer value: