Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > errors ???

Reply
Thread Tools

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
 
Reply With Quote
 
 
 
 
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.


 
Reply With Quote
 
 
 
 
Robert Stankowic
Guest
Posts: n/a
 
      08-31-2003

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


 
Reply With Quote
 
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>


 
Reply With Quote
 
David
Guest
Posts: n/a
 
      08-31-2003
Simon,
That was perfect!! Thanks alot.
David
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.Net- 0 Build Errors, but I am prompted that there were build errors? Lance Wynn ASP .Net 1 02-03-2008 12:20 AM
Out-of-memory errors and caching errors. George1776 ASP .Net 2 09-14-2006 03:34 PM
Obsolete Errors and Deprecated Errors using Dotnet Framework 2.0 SenthilVel ASP .Net 0 06-07-2006 11:48 AM
Internet Explorer causing errors/ slow internet speed and Outlook express errors Jeanne Medley Computer Support 2 02-11-2004 11:44 PM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM



Advertisments