why is the error in this program c++?
<p>I don't understand this program, I don't get why number is initialized to 1 when the program takes user input.
This is how I understand the program which is obviously wrong:</p>

<p>You enter the factorial number, lets says I enter 6, it goes to the while loop because 6 is greater than 1.
Now <code>factorial</code> is 1, and <code>number</code> is 6, <code>6 * 1 = 6</code>. Then <code>6 - 1 = 5</code>, so <code>factorial</code> is 5 but i get 720 as output.</p>

<p>i don't think I understand the while loop</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

int main()
{
    // declaration of the variables
    int factorial, number;

    // initialization of the variables
    factorial = 1;
    number = 1;

    // Prompt the user to enter the upper limit of integers
    cout &lt;&lt; "Please enter the number of the factorial";
    cin &gt;&gt; number;

    // using the while loop find out the factorial
    while (number &gt; 1)
    {
        factorial = factorial * number;
        number = number - 1;
    }
    cout &lt;&lt; "The factorial is " &lt;&lt; factorial;
}
</code></pre>
