Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
June 28th, 2013, 09:12 PM
 arman.khandaker
Contributing User

Join Date: Jun 2013
Posts: 116
Time spent in forums: 16 h 51 m 33 sec
Reputation Power: 1
Using a loop to calculate some stuff

Here's the code:
Code:
```#include <stdio.h>

int main(void)
{
float amount, interest, payment, a;
int n;

printf("Enter amount of loan: ");
scanf("%f", &amount);
printf("Enter interest rate: ");
scanf("%f", &interest);
printf("Enter monthly payment: ");
scanf("%f", &payment);
printf("Enter number of payments: ");
scanf("%d", &n);

printf("Balance remaining after %d payments: %2.2f\n", n, a);

return 0;
}```

The formula to calculate the balance remaining after 1 payment is: "a = (amount + (interest / 1200) * amount) - payment"
I am not sure how to code this into a loop that will calculate the sum left after n payments. Help me if you can. Thanks in advance

 Viewing: Dev Shed Forums > Programming Languages > C Programming > Using a loop to calculate some stuff