i have a problem (c)

This is a discussion on i have a problem (c) within the C Programming forums, part of the General Programming Boards category; plzzzzzz some body fix it i dont know whats wrong with my program #include <stdio.h> int factorial(int); int compute_e(int); int ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    3

    Unhappy i have a problem (c)

    plzzzzzz some body fix it
    i dont know whats wrong with my program


    #include <stdio.h>

    int factorial(int);
    int compute_e(int);
    int exponent(int,int);
    int exi(int,int);

    main()
    {
    int n,x;

    printf("enter\n");
    scanf("%d",&n);
    printf("fact=%d\n",factorial(n));
    printf("e=%d\n",compute_e(n));
    printf("enter an exponent of e\n");
    scanf("%d",&x);
    printf("e raised to%d=%d\n",x,exponent(x,n));
    return 0;
    }



    int factorial(int n) /*compute the factorial of n*/
    {

    int fact,i;

    fact=1;
    for(i=2;i<=n;++i);
    fact=fact*i;

    return fact;
    }
    int exi(int i,int x) /*calculate the value of (x raised to i)*/
    {

    int ex;
    ex=1;
    for(i=1;i<=x;++i)
    ex=ex*x;
    return ex;
    }


    int compute_e(int n) /* estimate the value of the mathematical constant e*/
    {
    int e,i;

    e=1;
    for (i=1;i<=n;++i)
    e=e+i/factorial(i);
    return e;
    }

    int exponent(int x,int n)
    {
    int exp,i;
    exp=1;
    for(i=1;i<=n;++i)
    exp=exp+exi(i,x)/factorial(i);
    return exp;
    }

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    3
    thanx a lot salem ,but i stil have a problem with copmputing the constant(e),and e raised to x
    Last edited by dodo; 03-28-2003 at 04:58 PM.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    3
    thaaaaaaaaaaaanx alot salem that was usefull i appriciate that

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 05:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM

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