Question: c- Programming Modify the output stream of the program runProgram and add functions to compute statistics in the file statistics.c. Currently the program reads in

 c- Programming Modify the output stream of the program runProgram and

add functions to compute statistics in the file statistics.c. Currently the program

reads in a stream of integers from standard input. It assumes that

there is 1 integer per line. The program starts reading when it

encounters a non-positive number or character. You will need to add below

c- Programming

Modify the output stream of the program runProgram and add functions to compute statistics in the file statistics.c. Currently the program reads in a stream of integers from standard input. It assumes that there is 1 integer per line. The program starts reading when it encounters a non-positive number or character. You will need to add below statistics to statistics.c (and edit add prototypes to statistics.h), so that each statistics is computed in a separate function, also you will need to refine the output (in the function drivers() in the file getInput.c), so it looks exactly as depicted below" Input file (read from standard Input) 1 3 XXX Outputs exactly line up the ":"): Sum: 10.00 Average: 2.50 Sum of Squares : 30.0 Sample Variance: 1.25 Minimum: 1 Maximum: 4 Before you implement - runprogram prints out the correct Average of 2.50 as a running average, but not in the proper output format. Below is the output of the program before starting. The content of input04.txt is listed by the cat command below: {csci-odiningrid:86} cat input04.txt 4 1 3 XXX {csci-odin: ingrid:84} runprogram Entered ---> 2 -> Running Average ---> 2.00 -> Entered ---> 4 -> Running Average ---> 3.00 -> Entered ---> 1 -> Running Average ---> 2.33 -> Entered ---> 3 -> Running Average ---> 2.50 -> End of input Only getInput.c and statistics.c and statistics.h need to modified. In getInput.c you only modify the function driver. * getinput.c statistics.c statistics.h runProgram.c 1 #include 2 #define MAX_LINE 80 3 // functions from statistics.c, prototype is in statistic.h 4 #include "statistics.h" 19 21 6 7 /* 8 * getIntegerLine() returns a positive integer from a line of input 10 11 Assumption: assumes proper input. 12 */ 13 int getIntegerLine() 14 15 char line[MAX_LINE]; 16 int return_user_int=-1; 17 18 fgets( line, sizeof( line ), stdin); while( sscanf( line, "%d", &return_user_int ) != 1 ) 20 { // Not a positive integer - indicates end of input return -1; } 24 return return_user_int; 25} 26 27 28 /* 29 prompts user for input. 30 */ 31 void promptlist) 32 33 printf(" Assumes proper input "); 34 printf(" Type a list of non-negative integers, below, one integer per line "); printf(" Indicate the END of input with any letter (a-z): ->" ); 36) 37 38 22 23 35 39 40 void driver) 41 { 42 int anumber=-1; 43 promptlist(); 44 45 46 47 48 49 50 51 52) 53 while( (anumber = getIntegerLine() >= 0 ) { printf("Entered ---> %d -> ", anumber ); printf("Running Average ---> %4.21f -> ", running_average anumber ) ); } printf("End of input " ); getInput.c X statistics.c statistics.h runP 1 1 2 3 double running_average int add_number ) 4 { static double total_numbers = 0; static double total_sum = 0; 5 6 7 8 9 total_sum = total_sum + (double) add_number; total_numbers += 1; 10 11 12} return total_sum / total_numbers; 13 1 * getInput.c statistics.c statistics.h runProgram.c 11/7 only include declaration once, by defining prepprocessor 'dummy variable' 2 #ifndef STATISTICS_H 3 #define STATISTICS_H 4 5 6 extern double running_average int add_number); 7 8 9 o #endif 1 2 3 getInput.c statistics.c statistics.h runProgram.c extern void driver(); int main() { driver(); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!