Answer:
void ranges(int x[], int npts, int *max_ptr, int *min_ptr)
{
*max_ptr=*min_ptr=x[0];
for(int i=1;i<npts;i++)
{
if(x[i]>*max_ptr) //this will put max value in max_ptr
*max_ptr=x[i];
if(x[i]<*min_ptr) //this will put min value in min_ptr
*min_ptr=x[i];
}
}
Explanation:
The above function can be called like :
ranges(x,n,&max,&min);
where x is array and n is number of elements and max and min are address of variables where maximum and minimum values to be stored respectively.