Here is just the while loop. The object is to add the integers in the file until the sum < = 1000.
Code:
sum = 0;
under = true;
while (inFile && under)
{
if (sum > 1000)
under = false;
else
sum = sum + num;
}
outFile << "The sum of integers which does not exceed 1000 is " << sum << "." <<endl;
inFile.close();
inFile.clear();