fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #define NUM 100
  5.  
  6. float Average(int []);
  7.  
  8. int main()
  9. {
  10. int n[NUM], i;
  11. srand(time(NULL));
  12.  
  13. for(i = 0; i<NUM; i++) {
  14. n[i] = rand()%100 + 1 ;
  15. printf("%d%c",n[i],(i%10==9)?'\n':'\t');
  16. }
  17.  
  18. printf("---------------------------------------------------------------------------\n");
  19. printf("Mean = %f", Average(NUM));
  20.  
  21. system("pause");
  22. return 0;
  23. }
  24.  
  25. float Average(int input[NUM])
  26. {
  27. int j, sum = 0;
  28. float k;
  29.  
  30. for(j = 0; j<NUM; j++)
  31. sum += input[j];
  32.  
  33. k = sum/NUM;
  34.  
  35. return k;
  36. }
Runtime error #stdin #stdout 0s 2160KB
stdin
Standard input is empty
stdout
Standard output is empty