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; }

7th Dec 2019, 12:27 PM
Jack
5 Answers
+ 1
@swim. Thank you very much. Very helpful comments. Btw, no I did not write the function.
7th Dec 2019, 12:58 PM
Jack
+ 1
@swim Thanks. I will change the name.
7th Dec 2019, 1:08 PM
Jack
0
you did not assign value to size, why n>=0 when n is not decreasing
7th Dec 2019, 12:40 PM
âśłAsterisKâśł
âśłAsterisKâśł - avatar
0
you mean in the line float min (a, size)?
7th Dec 2019, 12:48 PM
Jack
0
I now get the error: No matching function for call to 'min' for cout << " minimum = "<< min(a, size);
7th Dec 2019, 1:03 PM
Jack