Counter not giving the expected result
<p>I am writing a program for a C++ class that computes Armstrong numbers. The program works fine except each output line is supposed to read as:</p>

<pre><code>Armstrong number 1: xxx
Armstrong number 2: xxx
Armstrong number 3: xxx
Armstrong number 4: xxx, etc...
</code></pre>

<p>The computations are correct but the counter to give the incremental number "Armstrong number 1", 2, 3, etc only reflects the actual armstrong result. I need it to count the displayed lines. </p>

<p>The code is below.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;sstream&gt;
#include &lt;iomanip&gt;
#include &lt;cmath&gt;

using namespace std;

int main()
{
    // Change the console's background color.
    system ("color F0");

    // Declare the variables
    int i = 0, counter = 1, var1, var2, var3, var4;

    while (i &lt; 1000)
    {
        var1 = i/100;
        var2 = (i % 100) / 10;
        var3 = (i % 100) % 10;
        var4 = (var1 * var1 * var1) + (var2 * var2 * var2) + (var3 * var3 * var3);

        if (i == var4)

            cout &lt;&lt; "\n Armstrong number " &lt;&lt; counter &lt;&lt; ": " &lt;&lt; var4;
            counter++;
            i++;


    }
        cout &lt;&lt; "\n";
        system ("pause");
        return 0;
}
</code></pre>

<p>How do I fix this?</p>

<p>What I need is:
Armstrong number 1:   0
Armstrong number 2:   1
Armstrong number 3: 153
Armstrong number 4: 370</p>

<p>What I get is:
Armstrong number 0:   0
Armstrong number 1:   1
Armstrong number 153: 153
Armstrong number 370: 370</p>
