Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Specification Modify the above program, simplifying communications between functions. Implementation download program runningAveLocal2.c. define a function void r_avg(int input), which, given the current input input,

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Specification Modify the above program, simplifying communications between functions. Implementation download program runningAveLocal2.c. define a function void r_avg(int input), which, given the current input input, computes and displays the running average. Notice that unlike the function in A2, this function takes only one argument about current input and does not take current sum and input count as its arguments. In such an implementation, current sum and input count are not maintained in main. Instead, main just pass current input to r_avg(), assuming that r_avg() somehow maintains the current sum and input count info. do not modify or add to the code in main(). do not use any global variable. How can function r_avg maintain the current sum and input count info? 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 Enter number (-1 to quit): 47 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 main(int argc, char *argv[]) { int input; printf("Enter number (-1 to quit): "); scanf("%d", &input); while (input != -1){ r_avg(input); printf(" Enter number (-1 to quit): "); scanf("%d", &input); } return 0; } void r_avg(int input) { 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_2

Step: 3

blur-text-image_3

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

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions