I am trying to have my program print an array and also print the minimum value, all from a text file called numbers.txt
I have successfully printed the array with no errors, but I'm struggling to format the printing of the minimum value. I need to do this all from the file using getMin.
Any help would be greatly appreciated. Here's what I have so far:
Line 50: Min is uninitialized the first time through the loop. A handy way to deal with this is to initialize min to the first element in the array, and then have the array from from 1 to count instead of 0 to count:
1 2 3 4 5 6 7
int min = numbers[0];
for(int i=1; i<count; i++)
{
if(numbers[i] < min)
min= numbers[i];
}
This still has a bug when count is zero. I'll let you decide whether to fix it.
Line 54 ends the function getMin(), but you have more code at lines 56 & 57. ALso, should getMin() simply return the minimum value or should it print it? Decide what it should do, write a comment to reflect the design, and then make the code do what you want.