Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please complete the code in C Write a program testArray.c to initialize an array

ID: 3706507 • Letter: P

Question

Please complete the code in C

Write a program testArray.c to initialize an array by getting user's input. Then it prints out he minimum, maximum and average of this array. The framework of testArray.c has been given like below. Sample output: Enter6 numbers 11 12 4 90 1 -1 Min:-1 Max: 90 Average:19.5 #include // Write the declaration of function processArray int main(){ int arr[ 6]; int min-0,max-0; double avg-0; /* Write the statements to get user's input and initialize the array */ * Write the statement to call processArray */ processArray(int arr[l,int n, int *min, max, avg) printf ("Min: %d Max: %d Avg : %. 21f ", /* Write the corresponding expressions */); return 0; void processArray(int arr[],int n, int *min, int *max, double avg) /* Write the statements to calculate hr, min and sec/

Explanation / Answer

#include<stdio.h>
int main()
{
int arr[6];
int min=2147483647,max=-2147483648;
double avg =0;
printf("Enter 6 numbers: ");
int i;
for(i=0;i<6;i++)
scanf("%d",&arr[i]);
processArray(arr,6,&min,&max,&avg);
printf("Min:%d Max:%d Avg:%.1f ",min,max,avg);
return 0;
}

void processArray(int arr[],int n,int *min,int *max,double *avg)
{
int i,sum =0;
for(i=0;i<n;i++)
{
if(arr[i]<(*min))
*min = arr[i];
if(arr[i]>(*max))
*max= arr[i];
sum = sum+arr[i];
}
*avg = (double)sum/(double)n;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote