min. array with function..so close!

l;
}
system("pause");
return 0;
}[/code]
Last edited on
Well, to begin with, you don't initialize m in your min() routine.

You also begin your loop with an index of 1, not 0.
I cant initialize m in my function because the instructions state it has to be
double min(double array[], int size)
I don't think you understand what it means to initialize a value.

Here is how you can initialize m to the value of 12345, for example.

int m = 12345;

Here is your function, with m being initialized.

1
2
3
4
5
6
7
8
double min(double array[], int size)
{
   double min;
   double m = 12345;
   for (int c = 1; c < size; c++)
      if (array[c] < m) m = array[c];
   return min;
}



In your function, you never give min a value, but you return it. Looks to me like it's useless, and you're actually trying to make m the minimum value.
Last edited on
There's no reason you can't initialize it. I also notice that you define a variable min, but you never give it a value; you just return it. If your compiler chooses to do so, that means your function will return 0.0 for min; if not, the value will be unpredictable.

Try to do a little clean-up on your min() function, post back and we'll go from there.
OK i just rewro
system("pause");
return 0;
}[/code]
Last edited on
Some of your variable names aren't right. Your compiler should point this out to you.

And, you're still starting with an index of 1 instead of 0 in your GetMin function.
Topic archived. No new replies allowed.