Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

Define promotion.

Answered: 1 week ago

Question

Write a note on transfer policy.

Answered: 1 week ago

Question

Discuss about training and development in India?

Answered: 1 week ago

Question

Explain the various techniques of training and development.

Answered: 1 week ago

Question

Explain the various techniques of Management Development.

Answered: 1 week ago