{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

recitation9

# recitation9 - *min = x[i*mean=sum/i return 32.00 81.00...

This preview shows pages 1–2. Sign up to view the full content.

Sheet1 Page 1 R8_ 11/15/06 STA29 #include <stdio.h> #include <math.h> #define N 1000 int main (void) { double mean, max, min, x[N] int i=0, count void stats(double x[], int count, double *mean, double *max, double *min) FILE *input_file input_file = fopen("data9.txt", "r") while (fscanf(input_file, "%lf", &x[i])==1) i++ count=i for(i=0 i<count i++) { printf ("%6.2f ", x[i]) if((i+1)%10==0) printf("\n") } stats(x, count, &mean, &max, &min) printf("\nMAX = %6.1f\n", max) printf("MEAN= %6.1f\n", mean) printf("MIN = %6.1f\n", min) printf("\n\n") return 0 } void stats(double x[], int count, double *mean, double *max, double *min) { double sum=x[0] int i *max= x[0] *min= x[0] for(i=1 i<count i++) { sum+= x[i] if(x[i]>*max) *max = x[i] * if(x[i]<*min)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: *min = x[i] } *mean=sum/i return } 32.00 81.00 97.00 20.00 34.00 78.00 35.00 76.00 53.00 10.00 Sheet1 Page 2 11.00 35.00 75.00 86.00 25.00 86.00 12.00 24.00 30.00 42.00 74.00 58.00 42.00 48.00 95.00 25.00 67.00 31.00 47.00 75.00 25.00 35.00 23.00 47.00 58.00 96.00 25.00 74.00 69.00 10.00 25.00 73.00 57.00 42.00 35.00 46.00 68.00 52.00 34.00 68.00 96.00 24.00 63.00 57.00 85.00 24.00 11.00 36.00 77.00 64.00 32.00 36.00 79.00 80.00 31.00 25.00 46.00 74.00 MAX = 97.0 MEAN= 50.1 MIN = 10.0 Press any key to continue 345.60 98.70 432.10 56.70 123.40 234.50 87.60 135.70 76.50 246.80 64.2 MAX = 432.1 MEAN= 172.9 MIN = 56.7 Press any key to continue...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern