an unknown amount of float numbers (there could be thousands).
This is not a problem at all.. more than likely, just a scare tactic given to you by your teacher. All you have to do is continue to read in entries from your .txt file, until the file can no longer be read:
Code:
while(infile >> file_data)
{
//determine if the newly read file_data qualifies as a min
//determine if the newly read file_data qualifies as a max
// += accumulate the newly read file_data as a step in calculating the average
//++bump a counter so you'll know how many entries were read from the .txt file.. also a step in calculating the average
}
using arrays to calculate a max.. populate an array of floats.. use a nested for loop as a method to compare one element vs. every other element in the array:
Code:
float max = 0.0f;
for(int i=0; i<array_size; i++)
for(int j=0; j<array_size; j++)
{
if(array[i] > array[j] && array[i] > max)
max = array[i];
}
Just do the opposite to calcuate a min.