write and test a function that returns the difference between the largest and the smallest elements of an array-of- double . be sure to test (and include) all the edge cases you can think of to ensure your function works for all double variables.
1
Expert's answer
2021-10-13T10:43:41-0400
double diff(double *arr) {
int n = sizeof(arr) / sizeof(arr[0]);
double min = DBL_MAX;
double max = DBL_MIN;
for (int i = 0; i < n; i++) {
if (min > arr[i]) { min = arr[i]; }
if (max < arr[i]) { max = arr[i]; }
}
return max - min;
}
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment