Program C Write Function Computes Average Array Double Precision Values Assume Array Least Q37033398

Program in C. Write a function that computes the average of anarray of double precision values. Assume that the array has atleast one element.Fill in outline below please

#include <stdio.h>

double average( … )

{

.

.

.

}

int main()

{

int length = 7;

double ar[ ] = { 2.3, -1.2, 5.7, 9.0, -5.3, 12.6, 22.0 };

double avg = average( ar, 7);

printf (“Average: %lfn”, avg );

}


Answer


#include <stdio.h>double average( double arr[], int size ){ int i; double total = 0; for (i = 0; i < size; ++i) { total += arr[i];

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.