Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i need help with this Program as soon as possible This to start you off #include void r_avg(int, int); int main(int argc, char *argv[]) {
i need help with this Program as soon as possible
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 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 Enter number (-1 to quit): -1 red 309 % This to start you off
#include
void r_avg(int, int);
int main(int argc, 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started