Answer:
double* maximum(double *a, int size) {
if(size == 0)
return NULL;
int i;
double max = 0.0;
double *mp;
for(i = 0; i < size; i++){
if(a[i] > max){
max = a[i];
mp = &a[i];
}
}
return mp;
}
Step-by-step explanation:
You iterate through the vector and find the maximum value. You go updating the pointer throughout the loop. I am going to write a C function
double* maximum(double *a, int size) {
if(size == 0)
return NULL;
int i;
double max = 0.0;
double *mp;
for(i = 0; i < size; i++){
if(a[i] > max){
max = a[i];
mp = &a[i];
}
}
return mp;
}