Chris Pollett>Old Classes>PIC 10a, Spring 2000>Hw3>Hw3 FAQ

Spring 2000 PIC 10a HW3 FAQ Page

General questions and answers for this homework will be placed here as they arise.

Can I see an example of computing the standard deviation?

Yes. Consider the numbers 1,2,3,4. Their average is 2.5. The standard deviation is:

{[(1-2.5)2 + (2-2.5)2 +(3-2.5)2+(4-2.5)2]/4}1/2 = (5/4)1/2 =approx. 1.12

What would be good prototypes for the functions in problem2 page 210?

For the function that computes both the standard deviation and the average you can use:

void AvgAndStd(double s1, double s2, double s3, double s4, double& avg, double& stdev);

For the two auxiliary function you can use:

double Average(double s1, double s2, double s3, double s4);

double StdDev(double s1, double s2, double s3, double s4, double avg);

Note: these are my suggestions. If you used other prototypes meeting the requirements specified in the book then you should be okay. Notice in StdDev avg is call by value. i.e., you should have already computed it. Also the function AvgAndStd has its last two arguments as call by reference. Since you need to return two things you have to have these call-by-reference.

For problem 2 page 210 should the driver program get inputs from the user or should they be hardcoded?

Either way is fine. The former is probably preferable.