In your array_min function, you compare array[i] to min, but the problem is that the variable "min" is never initialized to any value, so you are comparing junk.
If your array only has positive numbers, I would make a very large value be the initial value of your min variable. ex:
double min = 10000.0;
___________
Second problem is that on line 7, you call array_min on your array1, but your array1 is never initialized with values, so the min value will be junk.
___________
Third problem is that you can't use cin on an array like that (line 9), you have to use a loop and do
1 2
|
for (int i = 0; i < size; i++)
cin >> array[i];
|
___________
Fourth problem is on line 10, you call array_min, but you never store the value anywhere.
So overall:
- before calling array_min, you need to make sure your array actually has non-junk values in it
- initialize the min variable inside your array_min function to some large number.