// Getting the adress of the maximum element of an array
#include <iostream>
#include <cmath>
using namespace std;

// Returns the address of the maximum element
double * maxAdr(double *array, int size){
  double  mval =  array[0];
  double *madr = &array[0];

  for(int i=1; i<size; i++){
     if(array[i] > mval) {
       mval =  array[i];
       madr = &array[i];
     }
  }
  return madr;
}

int main(){

  double  a[5] = {1.0, -2.0, 4.0, 8.0, -16.0};
  double *b;

   b = maxAdr(a, 5);

   cout << "the address of the maximum is " <<  b << endl;
   cout << "the value   of the maximum is " << *b << endl;

  return 0;
}
