Hi!!

I need a little help with my program.

I have done a program that calculates mean, variance and standard devisation now I need to add the calculation for confidence interval.

The confidence interval is calculated using this equation:

mean +/- z*(standard deviation/number of samples)

I have added this to my code:

Function prototype:double conf_int(double n[ ], double stv, double z);

and

double z;

printf ("Enter the z value");

scanf ("%d", &z);

This is wher I get stuck.

I am nto sure on how to do write the code for calculationg confidence interval.

The output for example should look like this: 73.125 +/- 69.536

This is my code

Code:#include <stdio.h> #include <math.h> #define N 12 /* Function prototypes */ double mean(double n[ ]); double variance(double n[ ], double m); double std_dev(double v); double conf_int(double n[ ], double stv, double z); void main(void) { double mu, v, stv; double num[N] = {87.8, 45.7, 56.7, 78.6, 49.7, 91.2, 87.6, 63.6, 59.8, 98.3, 77.2, 81.3}; double z; printf ("Enter the z value"); scanf ("%d", &z); /* int ctr; for (ctr=0; ctr<N; ctr++) { printf ("Please enter the next number . . . "); scanf ("%f", &num[ctr]); } printf ("fdls %f", num[1]); */ mu = mean (num); v = variance (num, mu); stv = std_dev(v); printf ("Mean = %.3f, Variance = %.3f\n", mu, v); printf ("Standard Deviation = %.3f\n", stv); printf ("Confidence Interval = %.3f\n", conf_int); } double mean(double n[N]) { double sum=0.0, retVal; int i; for (i=0; i<N; i++) { sum += n[i]; } retVal = sum/N; return retVal; } double variance(double n[N], double m) { double ctr=0.0, retVal; int i; for (i=0; i<N; i++) { ctr += pow ((n[i] - m), 2); } retVal = ctr/(N-1); return retVal; } double std_dev(double v) { double retVal; retVal = sqrt(v); return retVal; } double conf_int(double n[ ], double stv, double z); { ?????????????????????????????THANK YOU