I am trying to write a simple program that reads integers from a data file and outputs the minimum and maximum value. The first integer of the input file will indicate how many more integers will be read, and then the integers will be listed.
Example input file:
5 100 -25 42235 7 -1
As simple as this is, i’m not sure where to start. I imagine I will need to create an array of size = the first integer, then increment my position in the array and compare to a min/max value.
I am not sure what the syntax would be to declare an array with the first integer, then fill the array with the remaining integers, or if that is even the right approach. After creating the array, I should have no problem assigning values to min/max variables with a loop increasing position through the array.
There is no need to use an array to store data. You just need to find out minimum and maximum values from data received from a file.