Thread: home work help =)

  1. #1
    Registered User
    Join Date
    Mar 2002

    Arrow home work help =)

    this program calculates the approximate value of e to the x(e^x)
    and subtracts that value from the exact value. im not soo sure if its working correctly, well it runs but im not sure im getting the correct out put, its for a school hw assignment. also what is the place holder symbol for double, i have to do this program for double and for float.

    #include <stdio.h>
    #include <math.h>

    float factorial(float);//factorial function header
    float myE(float,float);

    float exponent_e,non_pierc,error_amt;
    float x=2.0;
    float n = 0;


    //printf("X= %f\n",x);



    printf("%.0f | %.12f \n",n,error_amt);


    return 0;
    float myE (float x, float n)
    if (n<1.0) return 1.0;
    return ((pow(x,n)/factorial(n)) + myE(x,n - 1.0));

    float factorial(float a)
    if(a <=1)
    return 1;
    return a * factorial(a -1);

  2. #2
    I think the placeholder for double is %lf, which stands for long float.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem in accessing root home folder....
    By Bargi in forum Linux Programming
    Replies: 1
    Last Post: 02-13-2008, 05:50 AM
  2. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 10:50 AM
  3. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 10:39 PM
  4. C++ software for home work
    By rgk44 in forum C++ Programming
    Replies: 12
    Last Post: 02-15-2006, 04:00 AM
  5. Problems in getting OpenGL to work
    By zonf in forum C Programming
    Replies: 5
    Last Post: 02-13-2006, 04:48 AM