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
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment