0
How to make use of the following min() function in the main() function?
Hello Can anyone help me to make use of the following min() function in the main() function? I need to have the minimum element in the array to be given by the function. How can I complete the code? #include <iostream> using namespace std; float min(float[], int); int main() { float a[]={22.2, 44.4, 66.6, 88.8, 44.4, 66.6, 55.5}, size; cout << "The minimum of the arrays is: \n"; float min (a, size); } float min(float a[], int n){ assert (n>=0); float min=a[0]; for (int i=1; i<n; i++) if (a[i] < min) min = a[i]; return min; }
8 odpowiedzi
+ 1
@swim. Thank you very much. Very helpful comments.
Btw, no I did not write the function.
+ 1
@swim Thanks. I will change the name.
0
you did not assign value to size, why n>=0 when n is not decreasing
0
you mean in the line float min (a, size)?
0
I now get the error:
No matching function for call to 'min'
for
cout << " minimum = "<< min(a, size);