Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C language programming function calculates and returns the average value of elements in integer array. Use this function to calculate and output the values of elements in two integer arrays.
C language programming function calculates and returns the average value of elements in integer array. Use this function to calculate and output the values of elements in two integer arrays.
# include & ltstdio.h & gt

# Definition number 100

Floating point average (int x[], int n)

{

int I;

Floating point s = 0;;

for(I = 0; I & ltn;; i++)

s+= x[I];

Returns the serial number;

}

int main()

{

int i,N,a 1[N],a2[N];

Printf ("Please enter the number of elements of the array 1:");

scanf("%d ",& ampn);

Printf ("Please enter %d array elements", n);

for(I = 0; I & ltn;; i++)

scanf("%d ",& ampa 1[I]);

Printf ("the average value of array 1 is %.4f.\n", avg(a 1, n)););

Printf ("Please enter the number of elements in array 2:");

scanf("%d ",& ampn);

Printf ("Please enter %d array elements", n);

for(I = 0; I & ltn;; i++)

scanf("%d ",& ampa2[I]);

Printf ("the average value of array 2 is %.4f.\n", avg(a2, n)););

}