Question: Type the following code in C language. Here is the starting code: #include #include int largest(int x[], int y); int main(){ const int MAX =
Type the following code in C language. Here is the starting code:
#include
#include
int largest(int x[], int y);
int main(){
const int MAX = 5;
int array[MAX], count;
//For loop for popluating array with random ints from 1-10
for (int i =0; i
array[i] = (rand()%10) +1;
}
//call function in print statement
printf("The largest element of array: %d", largest(array, MAX));
// Print array elements
printf(" The elements of array are: ");
for (int i = 0; i
printf("%d\t", array[i]);
}
return 0;
}
int largest(int x[], int y){
int count;
int biggest = x[0];
// for loop to compare each element with current biggest element
for (int i = 1; i if (biggest biggest = x[i]; } } return biggest; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
