I need to come up with range function that should take 2 parameters 1d int array and the number of elements. It should return the difference between the largest element and the smallest element.
so far I have this :
int range(int a[], int size) {
int max = a [0];
int min = a [0];
for (int i = 0; i <= size; i++) {
if (max < a[i]) {
max = a[i];
}
}
}
But I am getting incorrect values, can anyone help?