Tuesday, July 28, 2009

How can i make a C++ program?

How can I make a C++ prorgram such that when i input a number x it will output the exponential function or e^x where e is Euler's number.


I made one but it always output zero or some times the dialogue box saying if i would like to send error report appears:


#include%26lt;iostream.h%26gt;





int fact(int f)


{


int t;


t=1;


while (f%26gt;1)


{


t=t*f;


f=f-1;


}


return (t);


}





void main()


{


int x,e;


int n;





cout%26lt;%26lt;"Enter number"%26lt;%26lt;endl;


cin%26gt;%26gt;x;


e=1;


n=1;


while(e%26lt;=500)


{


n=n+x^e;


n=n/fact(e);


e++;


}


cout%26lt;%26lt;endl%26lt;%26lt;n;


return;


}


Please HELP me!!!

How can i make a C++ program?
in line 27 n=n/fact(e); your programm make a misstate


No comments:

Post a Comment