Question: C Programming question For a set of n real numbers {x1 , . . . , xn }, here are a number of basic statistics

C Programming question

For a set of n real numbers {x1 , . . . , xn }, here are a number of basic statistics we would like to know about the distribution of these numbers: The minimum value m = min{x1 , . . . , xn }. The maximum value M = max{x1 , . . . , xn }. The average value a = 1 n Pn i=1 xi . The standard deviation s = q1 n Pn i=1 (xi a) 2. Write a program stats.c that calculates these values for a sequence of values it reads from stdin. The input is provided as a sequence of n + 1 numbers, each on a separate line. The first number is n. The remaining n numbers are x1 , . . . , xn . Your program may assume that n 1000. For two bonus marks, your code should be able to handle any value of n, even values greater than 1000. For any given input, your program should print the output m = ... M = ... a = ... s = ... 2 to stdout, where the ... are to be replaced with the values of m, M, a, and s. Each output value should be represented with 3 digits after the decimal point. To generate some test data for your program, you can use the genseq program you created earlier. The invocation ./genseq generates a sequence of n random numbers and prints n followed by these n random numbers to stdout. Using ./genseq > seq.txt , you can save this output in a file seq.txt. You can use this as the test input for your stats program by running ./stats < seq.txt .

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!