I'm working on some code for school and ran into an issue. The assignment is as follows:
"Write a program which reads the numbers.txt file (available in BlackBoard in the Week 2 folder). The file contains a series of numbers, each written on a separate line. The program will read the contents of the file into an array and then display the following information:
the lowest number in the array
the highest number in the array
the total of the numbers in the array
the average of the numbers in the array."
So I have my code to read the file which has 12 random numbers listed out, each on a new line, when I execute the code, it lists 12 numbers, the first is actually the last number in the list and the rest are 858993460 which is obviously not correct. How do I get it to read the rest of the numbers properly? Once I get that worked out I know how to get the rest of the parts of the assignment working.
using namespace std;
const int ARRAY_SIZE = 12;
int count = 0;
while (count < ARRAY_SIZE && inputFile >> numbers[count]);
cout << "The numbers are: " << endl;
for (count = 0; count < ARRAY_SIZE; count++)
cout << numbers[count] << " " << endl;