this is a program i wrote to count the compound interest, but it's not working it's giving me following error message when i compile
"compound.c:(.text+0x69): undefined reference to `pow'
collect2: ld returned 1 exit status"
following the code
#include %26lt;stdio.h%26gt;
#include %26lt;math.h%26gt;
int main()
{
int rate;
int amount;
int p;
int n;
p=24;
printf("Rate\t\tAmount");
for(rate=5;rate%26lt;=10;rate++){
for(n=1; n%26lt;=381; n++){
amount=p*pow(1+(rate/100),n);
printf("%d\t\t%d", rate,amount);
}
}
return 0;
}
Need help with compound intertest program i am writing in C language?
You look like you are building with gcc and linux. Add '-lm' to link in the math library.
You will also want to chage 1+(rate/100) to 1.0+(rate/100.0) or something like that to make sure the math is done in floating point - as I don't think you want the integer truncation.
Good luck.
flowers uk
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment