www.pudn.com > λ²Ù×÷.zip > AVERAGE.C


#include  
float get_data (int *samp_size); 
float compute (int samp_size, float x_sum); 
void print_results (float average); 
   
main () 
   
/*   This program is to find the mean (average) and standard 
 deviation of a series of numbers.  The numbers will be read in 
 from the keyboard and printed on the screen.  Enter -1 when 
 finished.  Temporarily simplified and reading from a file instead */ 
   
     /* initialization of variables */ 
/* 1. Declare all variables needed and initialize them to zero.*/ 
{ 
    int samp_size=0; /* samp_size: number of variables read in*/ 
    float sum_of_x=0; /* this is the sum of the variables read in*/ 
    float answer; 
   
     /* get the data needed by the program */ 
    sum_of_x = get_data(&samp_size); 
   
     /* Now compute the answer */ 
    answer = compute(samp_size, sum_of_x); 
   
     /* Print the results out */ 
    print_results (answer); 
   
     /* Closing the brace on the main routine exits the 
     program.  There are other ways out, but this way will do for 
     now.*/ 
}