fork download
  1. #include<stdio.h>
  2. #include <math.h>
  3.  
  4. double calculatePayments(double rate, double loan, int payments);
  5.  
  6.  
  7. int main() {
  8.  
  9. double principal, i, monthlyP;
  10. int month;
  11.  
  12.  
  13. printf ("Enter the principal amount: ");
  14. scanf ("%lf", &principal);
  15.  
  16. printf ("Enter the interest amount: ");
  17. scanf ("%lf", &i);
  18.  
  19. printf ("Enter the term in months: ");
  20. scanf ("%d", &month);
  21.  
  22. monthlyP = calculatePayments (i, principal, month);
  23.  
  24. printf ("The monthly payment amount is %.2f: ", monthlyP);
  25. return 0;
  26. }
  27.  
  28.  
  29. double calculatePayments(double rate, double loan, int payments) {
  30. double mul = pow(1+rate, payments);
  31. return (loan * mul * rate) / (mul - 1);
  32. }
Success #stdin #stdout 0s 5292KB
stdin
300000
0.05
360
stdout
Enter the principal amount: Enter the interest amount: Enter the term in months: The monthly payment amount is 15000.00: