Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Specification Complete the ANSI-C program runningAveLocal.c, which should read integers from the standard input, and computes the running (current) average of the input integers. The

image text in transcribed
image text in transcribed
Specification Complete the ANSI-C program runningAveLocal.c, which should read integers from the standard input, and computes the running (current) average of the input integers. The program terminates when -1 is entered. Implementation Define a function void r_avg(int sum, int count) which, given the current sum sum and the total number of input count, computes and displays the running average in double. The current sum and input count are maintained in main. Complete main so that input is read and maintained. Sample Inputs/Outputs: red 307 $ gcc -Wall runningAveLocal.c red 308 % a. out Enter number (-1 to quit): 10 running average is 10 / 1 = 10.000 Enter number (-1 to quit): 20 running average is 30 / 2 = 15.000 Enter number (-1 to quit): 33 running average is 63 / 3 = 21.000 47 Enter number (-1 to quit): running average is 110 / 4 = 27.500 Enter number (-1 to quit): 51 running average is 161 / 5 = 32.200 Enter number (-1 to quit): 63 running average is 224 / 6 = 37.333 -1 Enter number (-1 to quit): red 309 % #include void r_avg(int, int); int main(int arge, char *argv[]) { int input; int count=0; int sum=0; printf("Enter number (-1 to quit): "); scanf("%d", &input); while(input != -1) { r_avg(sum, count); /* read again */ } return 0; } void r_avg(int sum, int count) { double resu = printf("running average is ....", }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions

Question

How is the NDAA used to shape defense policies indirectly?

Answered: 1 week ago