Question: Write a program to read from a binary data file (Lab4.dat). Sort the data in ascending order (smallest to largest). Find the minimum value, maximum

Write a program to read from a binary data file (Lab4.dat). Sort the data in ascending order (smallest to largest). Find the minimum value, maximum value, median value, mean, and standard deviation of the data set.

Lab4.dat is a binary data file that contains 200 doubles in random order, valued in the range (-1.0, 1.0). So I expect the mean pretty close to zero. The min should be element zeroth, the max element 199th, and the median element 99th.

See Fig 7.2, page 384-385 in the text for how to set up your for loop to computer the mean (average) and standard deviation.

You have to modify the swap and sort functions to take in doubles instead of integers.

Once you have the array sorted, print them out to the console, 10 elements per row. So I expect to see 20 rows of data - sorted, see attached bitmap file for how to print your sorted data. Hint: use this format string if you want your data to look like mine:

printf("% 02.4f ", bin_arr[i]);

After printing your sorted data, also print the min, max, median, mean, and standard deviation

Here is what someone has helped me with so far - the problem is that even though it is compiling successfully, it keeps crashing when i run it, can someone tell me what is going on?

#include #include #include /*Insertion Sort with n size*/ void sort(double a[], int n) { int i,j; /* Declare integer i and j variables*/ double temp; /*Declare double variable temp*/ for( i=1; i=0 && a[j] > temp) /* create while loop check condition first element > 0 and first element > second element then*/ { /* insertion process is continued*/ a[j+1] = a[j]; j = j- 1; } a[j+1] = temp; /* temp value is stored int next elements*/ } } /* Create caclMeanSTD() function to caclulate mean and standard deviation*/ void calcMeanSTD(double x[],int n) { double sum=0.0,mean,std=0.0; /* declare and initialize double variables*/ int i,n1; /* Declare integer variables*/ for(i=0;imax) max=a[i]; /*check condition maximum element and stored max*/ else if(a[i]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!