I need help with prompting the user for an integer. Print out the factors of the integer in descending order.
A while loop can be used i suppose.
Please advise.
Thank you.
The error with value is due to two things. When it is first encountered it's value is unknown. And then later on via the cin the user inputs it's value but it is too late.
Yes, you have declared value, the problem is you haven't initialised it.
Just write out in plain English what you are trying to do here. It is not clear at all and a computer will not have a clue either.
What is n? Is it a number, character, file name, ... ? What value does n have?
What you have written as it stands is something like " as long as some integer called n which I don't know anything about in terms of size, is equal to an integer I do know about, which is not equal to -1 then ... "
BTW don't forget equality in logical statements is ==, not =
int num = 0;
Ask user for a number -> store it in num
Loop through numbers starting at num, decrementing
Use the modulo operator (%) to find the factors
if num % i is equal to 0, i is a factor
Print i