Name this program stats.c - This program below performs some basic statistics on
ID: 3796209 • Letter: N
Question
Name this program stats.c - This program below performs some basic statistics on an array of 5 integers. It must use the five functions indicated. You need to complete this program (write the five functions) #include #include void getData (int, int[]); double getMean (int, int[]); double getVariance (int, int[], double); double getstdDev (double); void printResults (double, double, double); int main () {int size = 5, array[5]; double mean, variance, stddev; getData (size, array); mean = getMean (size, array); variance = getVariance (size, array, mean); stddev = getStdDev (varoamce); printResults (mean, variance, stddev); return 0;}Explanation / Answer
solution--
double getMean(int s,int arr[])
{
int i=0;
double avg=0;
for(i=0;i<s;i++)
{
avg=avg+arr[i];
}
avg=avg/s;
return avg;
}
double getVariance(int s,int arr[],double avg)
{
double var=0;
int i=0;
for(i=0;i<s;i++)
{
var=var+(arr[i]-avg)*(arr[i]-avg);
}
var=var/s;
return var;
}
double getStdDev(double var)
{
return sqrt(var);
}
void printResults(double avg,double var,double stddev)
{
printf("mean=%lf,variance=%lf,stddev=%lf",avg,var,stddev);
}
I did not get what do you want getData function to do.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.