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: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;

}

Change the prototype and header of the largest function so it uses pointer notation instead of array notation. //Change x[] to pointer notation int largest(int x[], int y) Change the comparison statement in the function so it uses pointer notation instead of array notation. Your function should contain a statement that looks something like this: if(x[count] > biggest) biggest x [count]; In the above code, change both uses of x [count] to pointer notation. Hint 1: You will need to use pointer addition. Hint 2: Both changes will look the same

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!