More C++ Worries.

This is a discussion on More C++ Worries. within the C++ Programming forums, part of the General Programming Boards category; 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 ...

  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,825
    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: trifaze_mattu@lycos.com

    ---------------------------------
    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, 02:17 PM
  2. A class in a class
    By Unregistered in forum C++ Programming
    Replies: 11
    Last Post: 11-25-2001, 05:52 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21