Please just explain what is the wrong things in this code and fix it, just fix i
ID: 3841122 • Letter: P
Question
Please just explain what is the wrong things in this code and fix it, just fix it don't change the hole thing I'm tired of reposting the question several times, I'll be rating you answer so please do it correctly 5) The following function supposedly computes the sum and average of the numbers in the array a, which bas length n. Variables avg and sum point to variables that the function should modify. Unfortunately, the function contains several errors; find and correct them. void avg sum (double a0, int n, double 'avg, double *sum) int i sum 0.0; for (i 0; iExplanation / Answer
#include<stdio.h>
void avg_sum(double a[],int n,double *avg,double* sum);
int main()
{
double a[]={12.0,16.0,8.0};
double avg;
double s;
avg_sum(a,3,&avg,&s);
return 0;
}
void avg_sum(double a[],int n,double *avg,double* sum)
{
int i;
*sum = 0.0;
for(int i=0;i<n;i++)
*sum = *sum + a[i];
*avg=*sum/n;
printf("sum=%lf , avg =%lf",*sum,*avg);
}
------------------------------------------------------------------------------------------------------------------------------------------
output - sum=36.000000 , avg =12.000000