Question

In: Math

Develop a C-code to calculate average, median and standard deviation, using 5 numbers as data you...

Develop a C-code to calculate average, median and standard deviation, using 5 numbers as data you input from the keyboard from calculations and compare program output with the hand calculations shown with formula for average, median & standard deviation..

Use suggested approach below for developing the code (other approaches are also possible):

In main     define an array of size = 5,

Read in 5 decimal numbers and print the chosen numbers for input; Store input as a array and work with the array only;

define a pointer pointing to the beginning of an array,

pass the array using pointer to function to function_average to compute ‘average’ that is passed back to main;

pass the array using pointer to function to function_median to compute ‘median’ that is passed back to main;

pass the array using pointer to function_standard_derivation to compute ‘standard deviation’ that is pass bac to main;

print results of the computed ‘average’, ‘median’ and ‘standard deviation’ with words of

‘Average of the input five numbers are’, ‘Median of the input five numbers is’ and ‘Standard Deviation of the input five numbers is”

Create function_average

Create function_median,

Create function_standard_derivation

Solutions

Expert Solution

the code is given below

#include<stdio.h>

#include<math.h>

int main() {

double a,b,c,d,e; // Define 5 variables

double avg ,mean,sd; // define average , Mean, standard deviation

printf("Enter five numbers: \n");

scanf("%lf",&a);

scanf("%lf",&b);

scanf("%lf",&c);

scanf("%lf",&d);

scanf("%lf",&e);

int a1,b1,c1,d1,e1;

a1 = (int)a;

b1 = (int)b;

c1 = (int)c;

d1 = (int)d;

e1 = (int)e;

printf("\n\nData: %d %d %d %d %d\n",a1,b1,c1,d1,e1);

avg = (a+b+c+d+e)/ 5.0;

mean = (a + b + c + d + e) / 5.0;

sd = sqrt(((pow(a-mean,2)) + (pow(b-mean,2)) + (pow(c-mean,2)) + (pow(d-mean,2)) + (pow(e-mean,2)))/ 5.0);

printf("Results: \n Average = %6.4f\n Mean = %6.4f\n Standard Deviation = %6.4f\n",avg,mean,sd);

return 0;

}

Sample output

Enter five numbers:                                                                               

42                                                                                                

44                                                                                                

142                                                                                               

144                                                                                               

143                                                                                               

                                                                                                  

                                                                                                  

Data: 42 44 142 144 143                                                                           

Results:                                                                                          

Average = 103.0000                                                                               

Mean = 103.0000                                                                                  

Standard Deviation = 48.9980

if it helps to you, hit a thumbs up.

if you have any doubts, comment accordingly


Related Solutions

Calculate the mean, median, mode, variance, and standard deviation for the following data set. (5 answers,...
Calculate the mean, median, mode, variance, and standard deviation for the following data set. (5 answers, 0.4 pts each) Number of cigarettes smoked per day was recorded for 10 study subjects. Study Subject # of cigarettes smoked/day A 5 B 7 C 3 D 10 E 6 F 10 G 20 H 0 I 5 J 12
Pick any 5 different two digit numbers and calculate mean, median, standard deviation, range, 25th and...
Pick any 5 different two digit numbers and calculate mean, median, standard deviation, range, 25th and outlier if any.
Using Minitab, calculate the mean, standard deviation, variance, and median of the following four data sets....
Using Minitab, calculate the mean, standard deviation, variance, and median of the following four data sets. Comment on the results. A B C D 100 50 50 75 100 75 100 75 100 100 100 75 100 125 100 100 100 150 150 175
calculate the mean, median, mode, and standard deviation based on the data provided. Response # Q3:...
calculate the mean, median, mode, and standard deviation based on the data provided. Response # Q3: How many times have you called the police in the last year? 1 0 2 0 3 0 4 2 5 4 6 9 7 0 8 2 9 5 10 4 11 3 12 0 13 0 14 0 15 1 16 8 17 15 18 7 19 2 20 2 21 4 22 3 23 0 24 0 25 1 26 0...
Given the data set below, calculate the standard deviation standard deviation using the defining formula standard...
Given the data set below, calculate the standard deviation standard deviation using the defining formula standard deviation using the computing formula 8,41,24,19,15,12,47,12,33
Using the following set of data, please find the mode, median, standard deviation and t-test for...
Using the following set of data, please find the mode, median, standard deviation and t-test for females and males. Females: A.) Mean B.) Median C.) Standard Deviation D.) T-test Males: A.) Mean B.) Median C.) Standard Deviation D.) T-test FEMALES: Female 1 Time (in Seconds): 225.62  Simple reaction: 0.262 Female 2 Time (in Seconds): 400.04 Simple reaction: 0.234 Female 3 Time (in Seconds): 469.16 Simple reaction: 0.199 Female 4 Time (in Seconds): 386.39 Simple reaction: 0.259 Female 5 Time (in Seconds):...
Use BASH to make a code that takes any list of numbers and calculate the Median...
Use BASH to make a code that takes any list of numbers and calculate the Median and Mode.
Suppose you calculated the mean, median, mode, and sample standard deviation of a data set. The...
Suppose you calculated the mean, median, mode, and sample standard deviation of a data set. The results are shown below. Mean: 44 Median: 31 Mode: 46 Sample Standard Deviation: 2 If each number in the data set was decreased by 4 units, what would be the new values of these statistics? Fill in your results below. New Mean: New Median: New Mode: New Sample Standard Deviation:
what is the mean, median, and standard deviation of the numbers 3, 7,11,12, 13, 19, 20,29,...
what is the mean, median, and standard deviation of the numbers 3, 7,11,12, 13, 19, 20,29, 34, and 42
Calculate Mean, Median, Mode, Quartiles, Percentiles, Population Variance, and Standard deviation from the following grouped data:...
Calculate Mean, Median, Mode, Quartiles, Percentiles, Population Variance, and Standard deviation from the following grouped data: Class.................. Frequency 2 - 4 .................   3 4 - 6 ..................... 4 6 - 8 .................... 2 8 - 10 ................... 1
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT