Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3.1.4 Stats When compiling homework scores, an instructor often wants to determine what is the minimum score, the maximum score, the mean and the standard

3.1.4 Stats

When compiling homework scores, an instructor often wants to determine what is the minimum score, the maximum score, the mean and the standard deviation.

The standard deviation of a set of data is a measure of the spread of the data values around the mean. For example, a small standard deviation indicates that the data values are all relatively close to the average value. For N data items, the standard deviation of array X is given by the following formula:

Practically, you can first accumulate the sum of the squares of the data values in the loop that processes the array (in a temporary variable). After the loop, you can then easily run the formula above.

Write program stats.c which reads a certain number of values from the user and displays some statistics about the sequence of numbers, as illustrated in the following example.

$ ./stats 5 4.34 23.4 18.92 -78.3 17.9 Min: -78.30 Max: 23.40 Avg: -2.75 Std: 38.31 $ cat data.txt 4 10.0 15.0 25.0 30.0 $ ./stats < data.txt Min: 10.00 Max: 30.00 Avg: 20.00 Std: 7.91 $ ./stats -1 Invalid size $ ./stats 2 a Invalid input $ 

The maximum number of numbers that can be read is 20. There is no dynamic memory allocation for this problem, you can just define an array of the maximum size.

In addition to the main function, your program should use one extra function:

void get_stats(double numbers[], int count, double *max, double *min, double *avg, double *stdev) which receives an array counting count elements and computes the maximum and minimum values in max and min, the mean value in avg and the standard deviation in stdev.

For this problem, you should use the math library.

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

Step: 3

blur-text-image

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

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions