Can someone explain why the program shows me 6 and 4? : <p>In this problem,which is an easy and a simple one, i do the sum and the product. I wanted to do with a "for" instruction to understand how this thing is working.</p>

<pre><code>#include &lt; iostream &gt;
using namespace std;
int main()
{
    int n,i,s=0,p=1;
    cin&gt;&gt;n;
    for (i=1;i&lt;=n;i++)
         s=s+i;
         p=p*i;

        cout&lt;&lt;s&lt;&lt;" "&lt;&lt;p;
}


</code></pre>

<p>I can't explain why the result is "6" for sum and "4" for product...</p>

<p>Can someone explain me why the code is showing this?
If i put the instructions from the "for" structure between of braces,it is showing "6" for sum and "6" for product.</p>
