Thread: Need help with e constant approximation program

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    7

    Need help with e constant approximation program

    I have to write a program using the formula e = (1+1/1! + 1/2!+...+1/n!) to approximate the value of e. THe program should ask the user to type in a maximum value for the error in the approximation, where this error is the difference between the calculated approximate value and the real value of e. Then have the program display the final value of e obtained by each series and the number of iterations required to get the input accuracy for e. The real value of e to be used is 2.71828182845904523536. The program should work for errors as small as 0.00000001. The approximation should display correctly to twelve decimal places. Can anybody help me out i have no idea where to start?

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Write some code that prompts for user input; get it to compile.
    Output the value entered.

    Learn how to do loops.

    Read the forum policy on homework. http://cboard.cprogramming.com/c-pro...-homework.html

    Post your code and then, Ask a good question.

    Tim S.

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    7
    I'm starting to figure it out but I don't understand what it means by displaying the number of iterations required to get the input accuracy for e.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by tsjohnsoniii View Post
    The program should work for errors as small as 0.00000001.
    Good luck with that.


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by tsjohnsoniii View Post
    I'm starting to figure it out but I don't understand what it means by displaying the number of iterations required to get the input accuracy for e.
    theError = theRealE - yourCalculatedE

    Then stop if theError is less than required error.

    Then you display the number of times your did your loop.

    I am NOT giving anymore till YOU DO REAL WORK and Post Code.

    Tim S.

  6. #6
    Registered User
    Join Date
    Oct 2011
    Posts
    7
    Quote Originally Posted by stahta01 View Post
    theError = theRealE - yourCalculatedE

    Then stop if theError is less than required error.

    Then you display the number of times your did your loop.

    I am NOT giving anymore till YOU DO REAL WORK and Post Code.

    Tim S.
    Thanks I got it working. Sorry I didn't mean to make it seem like I wanted y'all to do my homework my mind just went blank for a while I just needed help getting back on track. Thanks again man.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with factorials in sin approximation
    By p_dub in forum C Programming
    Replies: 9
    Last Post: 10-12-2010, 12:22 PM
  2. Keeping program running at constant speed.
    By twinzen in forum C++ Programming
    Replies: 2
    Last Post: 07-31-2010, 03:15 AM
  3. Sine approximation Help
    By What111 in forum C Programming
    Replies: 8
    Last Post: 11-04-2007, 06:22 PM
  4. Pi Approximation
    By dasar in forum C Programming
    Replies: 6
    Last Post: 10-07-2007, 07:41 AM
  5. Rectangular Approximation Program Help
    By Noah in forum C Programming
    Replies: 4
    Last Post: 03-15-2006, 02:23 PM