I have to write a program that computes e^x to an accuracy of .0001. I have no idea how to do this so any help would be greatly appreciated...thanks.
the equation is:
ex = 1 + x + x2/2! + x3/3! + ... + xn/n! + ...

2. For decimal places, you want to store your value as a float or double, when calling printf, you'll want a %.4f in there, the ".4" specifies 4 decimal places.

I'm not sure about your equation, but, similar to a very recent post, which makes me think you guys have a CP104 assignment due soon...

The method that comes to mind for me is using a for loop that counts from 1 to the number of times you want to multiply (x), and then each time, multiply your total by your base number (e)...

Good luck

3. Break the formula down into workable units and then try to use loops, etc. to put things together.

result = e^x is the sum of an infinite number of terms

the first and second terms are special cases.

each term thereafter is the quotient of a numerator and denominator

the numerator of each term can be calculated based on a specific pattern

the denominator of each term can be calculated
based on a specific pattern.

calculate each numerator and denominator and hence, term, in sequence and add it to the prior result until the value of the term is neglible compared to the result, based on some criteria.

round the final answer off to a specified level of accurarcy.

4. ## LOOPS and/or RECURSION?

Welcome to the board Uconn2111 !

I'll bet you've just had a lecture or chapter on loops (or maybe recursion).

Get it working without a loop first... just a few terms. Note that there is no factorial built-into C++. You'll have to do that yourself too.

If you are still having trouble, post the code that you have so far.

Just in case you're wondering why you are getting vague answers and general suggestions, see the homework policy and forum guidelines. Also read about code tags before posting any code.

5. Your program sounded like fun so i programmed it.....
Show us ur program thus far or what you think you should do, that way we can help you rather than tell u.