trying to calculate an estimat of e^x, where x is an integer entered by the user
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/827706/calculating-ex-without-using-any-functions">Calculating e^x without using any functions</a>  </p>
</blockquote>



<p>my attempt</p>

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

double myE(int num);

int main(){

    double e = myE(10);
    cout&lt;&lt;"e is "&lt;&lt;fixed&lt;&lt;showpoint&lt;&lt;setprecision(5)&lt;&lt;e&lt;&lt;endl;
    return 0;
}
double myE(int num){

    double e = 0;
    double factorial = 1;
 int x;
 cout&lt;&lt;"Enter a value for x in the expression e^x:"&lt;&lt;endl;
 cin&gt;&gt;x;

    for(int j = 0; j &lt;= num; j++){

        for(int i = 1; i &lt;= j; i++){

            factorial = factorial * i; 
        }
  for(int k = 0; k &lt;= x; k++){


        e = e + x / factorial; 
        factorial = 1;
  }}

    return e; 
}
</code></pre>

<p>i keep getting the wrong answer .. what am i doing wrong</p>
