home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / CNEWS018.ZIP / BEGINNER.ZIP / AVERAGE.C next >
Text File  |  1989-11-14  |  1KB  |  33 lines

  1. #include <stdio.h>
  2. float get_data (int *samp_size);
  3. float compute (int samp_size, float x_sum);
  4. void print_results (float average);
  5.   
  6. main ()
  7.   
  8. /*   This program is to find the mean (average) and standard
  9.  deviation of a series of numbers.  The numbers will be read in
  10.  from the keyboard and printed on the screen.  Enter -1 when
  11.  finished.  Temporarily simplified and reading from a file instead */
  12.   
  13.      /* initialization of variables */
  14. /* 1. Declare all variables needed and initialize them to zero.*/
  15. {
  16.     int samp_size=0; /* samp_size: number of variables read in*/
  17.     float sum_of_x=0; /* this is the sum of the variables read in*/
  18.     float answer;
  19.   
  20.      /* get the data needed by the program */
  21.     sum_of_x = get_data(&samp_size);
  22.   
  23.      /* Now compute the answer */
  24.     answer = compute(samp_size, sum_of_x);
  25.   
  26.      /* Print the results out */
  27.     print_results (answer);
  28.   
  29.      /* Closing the brace on the main routine exits the
  30.      program.  There are other ways out, but this way will do for
  31.      now.*/
  32. }
  33.