I am running into this issue where I want the largest and smallest value of id from a file that I am reading. This file contains other information as well. I am successfully able to identify the largest value but the smallest is just being set to the last value that gets read, which is not the smallest in the file. Here is the code
largestId = 0;
smallestId = 99999;
while(theFile >> firstName >> lastName >> id)
{
if(id > largestId){
largestId = id;
}else if(id < smallestId){
smallestId = id;
}
}