/****
 *
 * This program computes simple statistics for three real numbers read from
 * standard input.  The statistics computed are the sum of the numbers, the
 * arithmetic mean, and the standard deviation.  The results are output to
 * standard output, in the following form:
 *
 * Sum = 
 * Mean =
 * Standard Deviation =
 *
 * The precise formulae for mean and standard deviation are as defined here:
 *
 *    http://www.gcseguide.co.uk/statistics_and_probability.htm
 *
 *
 * Author: Gene Fisher (gfisher@calpoly.edu)
 * Created: 31mar11
 * Last Modified: 4apr11
 *
 */

#include <stdio.h>
#include <math.h>

#define NUM_DATA_POINTS 3               /* Fixed number of data points */

int main () {

    double x1, x2, x3;                  /* Input variables */
    double sum;                         /* Computed sum */
    double mean;                        /* Computed mean */
    double std_dev;                     /* Computed standard deviation */

    /*
     * Prompt the user for the input.
     */
    printf("Enter three real numbers, separated by spaces: ");

    /*
     * Input the numbers.
     */
    scanf("%lf%lf%lf", &x1, &x2, &x3);

    /*
     * Compute the sum.
     */
    sum = x1 + x2 + x3;

    /*
     * Compute the mean.
     */
    mean = sum / NUM_DATA_POINTS;

    /*
     * Compute the standard deviation.
     */
    std_dev = sqrt((pow(x1 - mean, 2) +
                    pow(x2 - mean, 2) +
                    pow(x3 - mean, 2)) / (NUM_DATA_POINTS - 1 ));

    /*
     * Output the results.
     */
     printf("Sum = %f\n", sum);
     printf("Mean = %f\n", mean);
     printf("Standard Deviation = %f\n\n", std_dev);

    return 0;

}