ok, i've got a question that i'm having trouble with
Write a program that generates the factors of a number entered by the user. This program has the following requirements:
1. The user must enter a positive integer. If the user enters something else, your program should output an error message and let the user enter a new value. Use a do/while loop to make sure the user input is successful.
2. The factors should be output in increasing order. The lowest factor your program should report is 2. Your program should output 4 factors per line, each factor is in a field of 10 characters.
3. You will need a while loop to report the factors. Here are some helpful hints:
a. If (a % b == 0) then a is a factor of b.
b. When you have found a factor, output the factor and then reduce the number you are working with by dividing the number by the factor… ie) b = b / a;
my problem is, i can get the program to factor out, but i dont know how to get it to output in increasing order, or with 4 factors per line, with each factor in field of 10, here is part of my code
if (factor%2 == 0)
{
cout << 2 << " ";
while (factor%2 == 0)
{
cout << factor << " ";
factor = factor/2;
}
}
i'm not asking for something to copy and paste, just some guidance