I am having trouble understanding why the numbers I have in my text file arn't being compared to find the largest number.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int largest = arr[1];
for (int i = 1; i < 10; i++)
{
if (largest < arr[i])
{
largest = arr[i];
}
}
cout << "The largest number is: " << largest << endl;
Assuming arr is of size len, on line 13 you are reading one number into a location past the end of the array. You need a loop to read in all the numbers.