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

write the program in c++ Pointen & A???ys: Write u function that is passed a poi

ID: 658675 • Letter: W

Question

write the program in c++


Pointen & A???ys: Write u function that is passed a pointer to a float array, and the size the array as an int. The function should return a pointer to the maximum element in the array The function should be: int *maxp(float* ap, int size) Write a main() program to lest the function with different input arrays. Grading Criteria (1 point each): Uses cin/cout correct function definition prompts user for input, reads it in correct function usage includes comments & meaningful variable names

Explanation / Answer

float *maxp(float *ap,int size)
{
float * max;
max=ap;
for(int i=1;i<size;i++)
{
if(* max<ap[i])
max=ap+i;
}
return max;
}
void main()
{
float array[10];
flaot * max;
cout<<"enter the elements";
for(int i=0;i<10;i++)
cin>>array[i];
max=maxp(array,10)
cout<<"the maximum element of the array is"<<*max;
cout<<"enter the elements";
for(int i=0;i<10;i++)
cin>>array[i];
max=maxp(array,10)
cout<<"the maximum element of the array is"<<*max;
getch();
}