i need help finding the low value in an array after reading file with numbers. With my program I am to assume that the size an array is 100 even if only 10, 31, 50 spaces are taken up.
The problem im running in to is when i iniztialize the array i set it equal to zero so all 100 space a filled with zero.
and for some reason whatever the program reads from the file(see file 1) when I call the Min function it only finds the 0's values that were not filled from the file.
file 1(lengthOfFile = 20, and the lowest value should be 39)
40
71
92
82
62
92
53
73
63
53
84
85
86
76
66
57
78
59
39
89
int main(void)
{
//Local Variables
double listArray[MAX_ARRAY_SIZE] = {0};
int lengthOfFile = 0;
double minVal = 0.0;
//Begin
lengthOfFile = GetInput(listArray);
minVal = Min(listArray, lengthOfFile);
DisplayStats(minVal);
}// end function main
double Min(double inputArray[], int inputLengthOfList)
{
//Local Variables
int i = 0;
double minVal = 0.0;
for(i = 0; i < inputLengthOfList; i++)
{
if(inputArray[i] < minVal)
minVal = inputArray[i];
}// end for
return minVal;
}// end function Min
Any help and suggestions would be greatly apperitated
Thanks
zingwing