I am having trouble understanding why the numbers I have in my text file arn't being compared to find the largest number.
int largest = arr;
for (int i = 1; i < 10; i++)
if (largest < arr[i])
largest = arr[i];
cout << "The largest number is: " << largest << endl;
Last edited on
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.
Thank you. What kind of loop would work for this?