Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that prompts the user to enter 10 numbers, and displays the mean

ID: 3548359 • Letter: W

Question

Write a program that prompts the user to enter 10 numbers, and displays the mean and standard deviations of these numbers.

In business applications, you are often asked to compute the mean and standard deviation of data. The mean is simply the average of the numbers. The standard deviation is a statistic that tells you how tightly all the various data are clustered around the mean in a set of data. For example, what is the average age of the students in a class? How close are the ages? If all the students are the same age, the deviation is 0. Write a program that prompts the user to enter 10 numbers, and displays the mean and standard deviations of these numbers.

Explanation / Answer

#include <iostream>

#include<cmath>


using namespace std;


int main()

{

int arrNum[10]; //Array to hold all 10 numbers

int sum = 0;

double mean, var = 0, stdDev;

  

//Prompting user to enter all 10 numbers

cout<<"Enter 10 numbers:";

  

for(int i=0;i<10;i++)

{

cin>>arrNum[i]; //Reading all 10 numbers

sum = sum+arrNum[i]; //Finding sum of all the numbers

  

}

  

mean = sum/10;

  

for(int j=0; j<10;j++)

{

var = var +( (mean -arrNum[j] )* (mean -arrNum[j] ) ); //Finding the variance of all the numbers

}

  

stdDev = sqrt(var/10); //Finding the standard Deviation

  

cout<<"Mean of all numbers : "<<mean<<endl;

cout<<"Standard Deviation: "<<stdDev<<endl;

return 0;

  

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote