Hi everyone!
I am a beginner in c programming, and I would be very very grateful if someone coule take a look at my little program which I wrote and which unfortunately does not really work.
The program calculates the running time and the annuity of a credit, after receiving the necessary values.
However, the formula for the running time does not work. I tried to rewrite this formula, maybe I have made a mistake:
in my programm n is the running time, R is the annuity, S is the amount of the credit, m is the fixed fee and i is the lending rate in per cent.
Code:
#include <stdio.h>
#include<math.h>
double R,m,S,i;
double annuity()
{
double R = 12*m;
return R;
}
int term()
{
int n = -(log(1-(i*S/R))/log(1+i));
return n;
}
main()
{
printf("\nFill in a value for S: ");
scanf("%lf",&S);
printf("\nFill in a value for m: ");
scanf("%lf",&m);
printf("\nFill in a value for i: ");
scanf("%lf",&i);
printf("\n\nThe annuity is %.2lf",annuity());
printf("\nThe running time is %i\n\n", term());
}
Thank you in advance and sorry for my bad english!