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

4. Write a program with the following functions, a) void fillArray ( int x[], in

ID: 1863389 • Letter: 4

Question

4. Write a program with the following functions,

a) void fillArray(int x[],int size) : reads data and store it in an array.

b) void printArray (int x[],int size) : prints the array.

c) int largestElement( int x[],int size) : finds and returns max element in an Array.

d) int minimumElement(int x[],int size) : finds and returns minimum element in an Array.

e) int sumArray ( int x[],int size) : finds and returns the sum of an array.

f) float avgArray( int x[],int size) : finds the average of an Array. Call sumArray function to calculate sum. DO NOT REPEAT THE CODE TO FIND THE SUM.

g) void copyArray( int x[], int y[], int size) : copies array x into array y. Array y must be atleast as large as the array x.

Write main method to test all methods.

Explanation / Answer

void fillArray(int x[],intsize)

{

int i;

for(i=0;i<intsize;i++)

scanf("%d",i+n);

}
void printArray (int x[],intsize)

{

int i;

for(i=0;i<intsize;i++)

printf("%d",i[n]);

}

int largestElement( int x[],intsize)

{

int i,largest=x[0];

for(i=0;i<intsize;i++)

if(x[i]>largest) largest = x[i];

return largest;

}
int minimumElement(int x[],intsize)

{

int i,smallest=x[0];

for(i=0;i<intsize;i++)

if(x[i]<smallest) smallest = x[i];

return smallest;

}
int sumArray ( int x[],intsize)

{

int i,sum=0;

for(i=0;i<intsize;i++)

sum += x[i];

return sum;

}
float avgArray( int x[],intsize)

{

return sumArray(x,intsize)/intsize ;

}
void copyArray( int x[], int y[], intsize)

{

int i;

for(i=0;i<intsize;i++)

y[i]=x[i];

}

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