Calculating the sum in C++
<p>How do I calculate the sum to below in C++?
I tried the following code but failed.</p>

<p><img src="http://i.stack.imgur.com/4kjJv.gif" alt="enter image description here"></p>

<pre><code>#include &lt;iostream&gt;
using namespace std;
int main()
{
    int n, p, r = -1;
    cin &gt;&gt; n;
    for (p = 0; p &lt; 10; p++)
        r *= (-1);
    cout &lt;&lt; r &lt;&lt; endl;
    return 0;
}
</code></pre>
