Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in C, compile, test, debug, and comment the following program. You must name your programs source file stats.c. Use consistent style and

Write a program in C, compile, test, debug, and comment the following program. You must name your programs source file stats.c. Use consistent style and naming conventions. We must be able to open this file using the Cloud9 editor to look at your code. Statistics are used for anything you can think of that can be expressed as numbers, and are used every day in newspaper articles, casual conversations, etc. There is a famous quote (There are three kinds of lies: lies, damned lies, and statistics), which emphasizes that you should understand how statistics are computed and what they mean, otherwise you will be easily misled. C is a great language for doing statistical (and other) calculations on large datasets. Write a program that reads in a set of numbers into an array, and then computes some standard statistics on the numbers. The numbers are real numbers, read in as double precision floatingpoint numbers, one number per line, possibly with some white space before or after. Hint: use scanf. There are guaranteed to be no more than one million (thats 106 ) numbers in the input, and no fewer than two legitimate numbers. Any number that is equal to zero should be ignored (discarded, not stored in the array or counted in any way). Note: We will test your code with different sets of numbers. Both the quantity of numbers and the numbers themselves will vary from the given test cases (see below). The statistics to compute are: The count of numbers read (remember, ignore zeros) the sum of the numbers The max and min of the numbers The arithmetic and harmonic means The variance Very Important: Each calculation must be done by a separate function. You can refer to a standard source on statistics or Wikipedia to review the definitions of these. When completed, print the output using the following format specifiers in the following sequence: "The count of numbers read from the input is %9d " "The sum of these numbers is %20.10f " "The max and the min of these numbers are %20.10f and %20.10f " "The arithmetic and harmonic means are %20.10f and %20.10f " "The variance is %20.10f " For the following input: 1 2 0 3 4 5 0 6 The output should be:

The count of numbers read from the input is 6

The sum of these numbers is 21.0000000000

The max and the min of these numbers are 6.0000000000 and 1.0000000000

The arithmetic and harmonic means are 3.5000000000 and 2.4489795918

The variance is 2.9166666667

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 Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago