Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a test program that prompts the user to enter 10 numbers and displays the mean and deviation, as shown in the following sample run:

Write a test program that prompts the user to enter 10 numbers and displays the mean and deviation, as shown in the following sample run:

Your program should contain the following functions:

// Compute the mean of an array of double values double mean(const double x[], int size) // Compute the deviation of double values double deviation(const double x[], int size) 

Write a test program that prompts the user to enter 10 numbers and displays the mean and deviation, as shown in the following sample run:

ex:

Enter ten numbers: 1.9 2.5 3.7 2 1 6 3 4 5 2 The mean is 3.11 The standard deviation is 1.55738

So this what I have:

#include #include

using namespace std;

void displayVals(int vals[], int numVals, int sum); void getVals(int vals[], int numVals); double average(int sum, int numVals); double stanDev(int vals[], double mean, int numVals);

int main() { int numVals=10; int sum = 0; int vals[9];

getVals(vals, numVals); cout << endl; displayVals(vals, numVals, sum); cout << endl;

}

void getVals(int vals[], int numVals) { int index; cout << "Enter ten numbers :" << " "; for (index = 0; index < numVals; index++) { cout << index + 1; cin >> vals[index]; } }

void displayVals(int vals[], int numVals, int sum) { int index; for (index = 0; index < numVals; index++) { cout << index + 1; cout << vals[index] << ". "; }

cout << endl; cout << "The mean is "; cout << average(vals, numVals, sum) << ". ";

cout << endl; cout << "The standard deviation is: "; cout << stanDev(vals, numVals, sum) << ". ";

}

double average(int sum, int numVals) { double dsum = (double)sum; double dnumVals = (double)numVals; return dsum / dnumVals; }

double stanDev(int vals[], double mean, int numVals) { double sum = 0, dVals = 0, value = 0, variance = 0; for (int i = 0; i < numVals; i++) { dVals = (double)vals[i]; value = (dVals - mean)*(dVals - mean); sum += value; variance = sum / (numVals); } return sqrt(variance); }

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

T Sql Fundamentals

Authors: Itzik Ben Gan

4th Edition

0138102104, 978-0138102104

More Books

Students also viewed these Databases questions

Question

1-4 How will MIS help my career?

Answered: 1 week ago