errors ???

Discussion in 'C Programming' started by David, Aug 31, 2003.

  1. David

    David Guest

    I posted this program earlier today and some of you helped me greatly
    with this program. However, I am receiving an error that I do not
    understand. Thanks for your help; I appreciate it.

    >>/var/tmp/ccoEynee.o: In function 'main':
    >>/var/tmp/ccoEynee.o(.text+0xfc): undefined reference to 'pow'
    >>collect2: ld returned 1 exit status



    Here is the program:

    #include <stdio.h>
    #include <math.h>
    #define principle 100000

    int main(void)
    {

    int time, years, interest;
    double monthlypayment, amount, r, q, n;

    printf(" Mortgage Payment Plan\n");
    printf("Principle Interest Rate Duration Monthly Payment Total
    Payment\n");

    for(interest=6; interest<11; interest+1)
    {
    for(time=5; time<35; time+5)
    {
    n = interest/100; //n is really the interest variable
    years = time*12;
    r = (1/ (1+n/12)); //r is just seperating code
    q = pow(r, years); //q is just seperating code
    monthlypayment = (principle*n/12) / (1-q);
    amount = monthlypayment*time*12;
    printf("%d %.2f %d %.2f %.2f", principle, n, time,
    monthlypayment, amount);
    }
    }
    return 0;
    }

    David
     
    David, Aug 31, 2003
    #1
    1. Advertising

  2. David

    Simon Biber Guest

    "David" <> wrote:
    > I posted this program earlier today and some of you helped me greatly
    > with this program. However, I am receiving an error that I do not
    > understand. Thanks for your help; I appreciate it.
    >
    > >>/var/tmp/ccoEynee.o: In function 'main':
    > >>/var/tmp/ccoEynee.o(.text+0xfc): undefined reference to 'pow'
    > >>collect2: ld returned 1 exit status


    http://www.eskimo.com/~scs/C-faq/q14.3.html

    You need to explicitly tell your linker to include the library of
    maths functions. This is a common problem on Unix systems.

    Usually adding the option -lm (dash ell em) to the end of your
    command line when building a C program should fix it.

    --
    Simon.
     
    Simon Biber, Aug 31, 2003
    #2
    1. Advertising

  3. David, please read below

    > I posted this program earlier today and some of you helped me greatly
    > with this program. However, I am receiving an error that I do not
    > understand. Thanks for your help; I appreciate it.
    >
    > >>/var/tmp/ccoEynee.o: In function 'main':
    > >>/var/tmp/ccoEynee.o(.text+0xfc): undefined reference to 'pow'
    > >>collect2: ld returned 1 exit status

    >
    >
    > Here is the program:
    >
    > #include <stdio.h>
    > #include <math.h>
    > #define principle 100000
    >
    > int main(void)
    > {
    >
    > int time, years, interest;
    > double monthlypayment, amount, r, q, n;
    >
    > printf(" Mortgage Payment Plan\n");
    > printf("Principle Interest Rate Duration Monthly Payment Total
    > Payment\n");
    >
    > for(interest=6; interest<11; interest+1)

    interest += 1 ^^^^^^^^^^

    > {
    > for(time=5; time<35; time+5)

    time += 5 ^^^^^^^

    > {
    > n = interest/100; //n is really the interest variable

    n = interest / 100.0
    otherwise the division is done with integers and the result is always 0

    > years = time*12;
    > r = (1/ (1+n/12)); //r is just seperating code
    > q = pow(r, years); //q is just seperating code

    I have absolutely no idea what the above comments mean...
    And btw, please use the /**/ style comments, they are supported in c89 and
    still working when your lines wrap in the newsreader.

    > monthlypayment = (principle*n/12) / (1-q);
    > amount = monthlypayment*time*12;
    > printf("%d %.2f %d %.2f %.2f", principle, n, time,
    > monthlypayment, amount);
    > }
    > }
    > return 0;
    > }
    >

    I did not check your calculations
     
    Robert Stankowic, Aug 31, 2003
    #3
  4. David

    Tim Cambrant Guest

    "Robert Stankowic" <> skrev i meddelandet
    news:3f51b278$0$37498$...
    > interest += 1
    >


    Wouldn't interest++ be a better idea?

    --
    Tim Cambrant
    <tim at cambrant dot com>
     
    Tim Cambrant, Aug 31, 2003
    #4
  5. David

    David Guest

    Simon,
    That was perfect!! Thanks alot.
    David
     
    David, Aug 31, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    973
    Mark Goldin
    Jan 17, 2004
  2. SenthilVel
    Replies:
    0
    Views:
    953
    SenthilVel
    Jun 7, 2006
  3. George1776

    Out-of-memory errors and caching errors.

    George1776, Aug 28, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    1,306
    George1776
    Sep 14, 2006
  4. Lance Wynn
    Replies:
    1
    Views:
    1,854
    Lance Wynn
    Feb 3, 2008
  5. yawnmoth
    Replies:
    97
    Views:
    4,735
    Bent C Dalager
    Feb 27, 2009
Loading...

Share This Page