fork download
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int n, count = 1;
  5. float x, average, sum = 0;
  6. printf("How many numbers? ");
  7. scanf("%d", &n);
  8. while ( count <= n)
  9. {
  10. printf("x = ");
  11. scanf("%f", &x);
  12. sum += x;
  13. count++;
  14. }
  15. average = sum/n;
  16. printf("\nThe average is %f\n",average);
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
How many numbers? 
The average is -0.000000