Velocity Reviews > errors ???

# errors ???

David
Guest
Posts: n/a

 08-31-2003
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

Simon Biber
Guest
Posts: n/a

 08-31-2003
"David" <(E-Mail Removed)> 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.

Robert Stankowic
Guest
Posts: n/a

 08-31-2003

> 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

> 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

Tim Cambrant
Guest
Posts: n/a

 08-31-2003
"Robert Stankowic" <(E-Mail Removed)> skrev i meddelandet
news:3f51b278\$0\$37498\$(E-Mail Removed) y.telekom.at...
> interest += 1
>

Wouldn't interest++ be a better idea?

--
Tim Cambrant
<tim at cambrant dot com>

David
Guest
Posts: n/a

 08-31-2003
Simon,
That was perfect!! Thanks alot.
David