errors ???

D

David

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.


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
 
S

Simon Biber

David said:
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.

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.
 
R

Robert Stankowic

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.



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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top