Total programming newbie here looking for some guidance.
So I have this assignment where I need to write a program that takes numbers from an input file and spits out said numbers factors. The catch is as soon as the read hits a negative number, the program is supposed to break the loop and end, even if there are values in the input file after the negative number.
I tried inserting another "if" statement within the "for" loop to no avail and I don't think changing the statements in the "for" loop would work.
I noticed if the number is larger than 9999, your code "cout << setw(5) << i;" isn't effective, you might use a tab instead. or some other spacing for large numbers.
For numbers up to 7 digits, try cout << "\t" << i;
int number ;
// while a. we have been able to read a number from the input stream
// b. and the number is non-negative
while( ( std::cin >> number ) && ( number > 0 ) )
{
// find the factors of the number and print them out
}