Question: This is C program And i need complete running code for this assignment please. Exercise 1. (50 points) Running average. Write a C program average.c
Exercise 1. (50 points) Running average. Write a C program average.c that reads floating-point numbers (double) from the standard input and, after reading cach number, prints the running total and average of the numbers that have been read so far. The program must terminate when there is an error or the end of file (EOF) is detected at the standard input (e.g., when the user presses Ctrl-D). The bloc bolo shows a sample execution ofthe prograrn in which the user provided input consists, n this order, of numbers 1, 2, le10 (1010), and 0: $/average Total-1.000000 Average-1.000000 Total-3.000000 Average-1.500000 e10 Total-10000000003.000000 Average-3333333334.333333 Total-10000000003.000000 Average-2500000000.750000 Notes. The loop needed to read the inpis similar to that used in xorbit.c in Lab 1: while (scanf("%1f", kx)-I) { // pay attention to %1f Di Here x is a double variable used to store the number read in each iteration. Printing the running total and average formatted as in the example above can be done using printf("Total.%f Average-%f ", total, average); // pay attention to %f where total and average are variables of type double
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
