1. ## calculate monthly payment

Hey guys, new to the board and C programming in general. I have this assignment that's giving me problems, don't know what's wrong.

Monthly Pay=[ rate + rate /([1+rate]^months -1)] X principle
Where rate of %6 means 6/1200
Months means number of years x 12

"Possible data to test:
Principle 12200
Rate 7%
Term in years 5
Monthly payment is: 241.57"

My code:

Code:
```#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void main ()
{
double princ, rate, term, monthly;

scanf("%lf", &princ);
scanf("%lf", &rate);
scanf("%lf", &term);

rate = (rate/1200);
term = (term*12);

monthly = ((rate + (rate/(pow((1 + rate),(term-1))))) * princ);

printf("Your monthly payment is: %f", monthly);

return 0;

}```
For my monthly payment I always end up getting half of what is expected. Any ideas?

2. The problem is the formula you are using. You are doing the following on the denominator.
Code:
`pow(1+rate, term-1)`
What you should be doing is this:
Code:
`pow(1+rate, term) - 1`
Btw, it is very bad programming technique to use 'void main()'. You should be using 'int main()' instead.

3. Thanks Swarvy! Just compiled it, changed the void as well, and it runs fine.