Friday, July 31, 2009

Help with C programming assignment?

Hello!!


I have dificulties figuring out how to add the calculation for confidence interval into my code. The equation for confidence interval is: mean +/- z* standard deviation/sqrt(number of samples)


Ok I have to add this calculation as well prompt the user for the z value, for example z value of 1.645.





I am new to C programming and don't understand it that much.


Any help would be appreciated.


I WAS NOT ABLE TO COMPY THE WHOLE CODE HERE. THIS IS THE BEGINING OF MY PROGRAM.


Thanks...


#include %26lt;stdio.h%26gt;


#include %26lt;math.h%26gt;


#define N 12





/* Function prototypes */


double mean (double num[ ]);


double variance (double num[ ], double m);


double std_dev (double v);





void main(void)


{





double m, 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};





m = mean (num);


v = variance (num, m);


stv = std_dev (v);


printf ("Mean = %.3f\n", m);


printf ("Variance = %.3f\n", v);


printf ("Standard Deviation = %.3f\n", stv);


}

Help with C programming assignment?
you have to give the chance to a expert for do this for you.


like http://expert.userstyle.org/
Reply:OK Im assuming the functions mean(), variance() and std_dev() exist and are being calculated correctly. All you need to do is make sure you:


1) Prompt the user for z and store this value, this would go in the main() function before m = mean(num);





double z;


printf ("Enter the z value for the Confidence Interval calculation\n");


scanf("%f", %26amp;z);





2) Your Confidence Interval formula has 2 values so you need to calculate 2 values according to the following.





/* Add these at the top of the main() function */


double ConfidenceIntervalMax=0;


double ConfidenceIntervalMin=0;





ConfidenceIntervalMax = m + (z*stv)/sqrt(N);


ConfidenceIntervalMin = m - (z*stv)/sqrt(N);





Now you can print these values or do whatever you like with them
Reply:Hi,


u have all the values to calculate confidence interval. for calculating the same u need to write numeric expression only.


ur C.I. is





mean - (Z * SD)


-------------


sqrt(n)





then calculate m - ((z*stv)/sqrt(n))


and m + ((z*stv)/sqrt(n))


or write


printf("(%f, %f)",m - ((z*stv)/sqrt(n)),m + ((z*stv)/sqrt(n)));





it will calculate and print C. I.

gift baskets

6 comments:

  1. Inheritance Tax UK Personal Tax Expert - Providing you with useful Tax Saving Tips, Inheritance Tax UK & Property Tax Calculator. Voted Number 1 source for financial information by Economia Readers.

    ReplyDelete
  2. Total Video Converter for Mac Total Video Converter for Mac is the best all-in-one Video Converter for Mac! With this ultra-fast Mac Video Converter,you can convert any video formats and burn your video to an optional DVD disc!
    Paint.Net Mac Paint.Net for Mac like MyBrushes, Pinta, and GIMP are
    some equivalents digital artists can choose to use Paint.Net Mac.



    ReplyDelete