What's wrong? How can I change the "sum1" order?
<p>I'm trying to compute the value of <code>cos x</code> using the Taylor series formula </p>

<pre><code>             infinity
             ----                  2k
             \            k      x
 cos(x) =    /        (-1)  * -------------
             ----                (2k)!
             k=0
</code></pre>

<p>Shown graphically at <a href="http://ppt.cc/G,DC" rel="nofollow">http://ppt.cc/G,DC</a></p>

<p>Here is my program.</p>

<pre><code>#include "stdafx.h"
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;cmath&gt;
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
    double sum=0.0,sum1=0.0;
 double x;
 cin&gt;&gt;x;
 for(int i=0 ; i&lt;=10 ; i=i+1 )
 {
  for(int i=1 ; i&lt;=20 ; i=i+1)
  {
   sum1=i*sum1+sum1;
  }
     sum=pow(-1,(double)i)*pow(x,(double)(2*i))/sum1+sum;
 }
 cout&lt;&lt;"Sum : "&lt;&lt;sum&lt;&lt;endl;
 system("pause");
 return 0;
}
</code></pre>

<p>The output is -1.#IND</p>

<p>Why?</p>

<p>How can I change the order of "sum1" to make it work right?</p>
