Thread: More C++ Worries.

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    7

    More C++ Worries.

    Can anyone help me with this extra credit problem?

    e^x= 1 +(x/1) + (x^2/2) + (x^3/6) = (x^4/24)...X^n/n!

    I have to read in x from the keyboard and use the exponential function on x and write the result.

    Then do the approximation for the first four terms, starting at 1 and write the results.

    Then write the difference between the two.


  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    Well... What's n?

    You could just use a loop - i think that'd be the easiest way... Have you made any headway on this since yesterday?

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    7

    Still Baffeled

    n is just the number of what power we raised it to. For example X^2/2!.

    I know I need the following libraries

    <iostream.h>
    <iomanip.h>
    <math.h>

    I am so glade you are there because this is due in a couple of hourse and I am TOTALLY stressed out!!!

  4. #4
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Lightbulb Well, to do this...

    To multiply a number and an exponent you just do this:


    int number1 = 2;
    int number2 = 3;
    int result = 0;

    result = number1 * exp(number2); // exp(...) is for exponent

    cout << result;
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: [email protected]

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. character pointer worries
    By kiss_psycho in forum C++ Programming
    Replies: 8
    Last Post: 12-26-2003, 03:17 PM
  2. A class in a class
    By Unregistered in forum C++ Programming
    Replies: 11
    Last Post: 11-25-2001, 06:52 AM