Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Write C program to calculate balance instalment
In C programming, calculating loan balance installments involves computing the remaining amount after each monthly payment, considering compound interest. This program demonstrates how to calculate the outstanding balance after making monthly payments on a loan with interest.
Syntax
balance = principal + (principal * (interest_rate / 100) / 12); remaining_balance = balance - monthly_payment;
Formula for Interest Calculation
The monthly interest calculation follows this approach −
-
Monthly Interest:
principal * ((annual_rate / 100) / 12) -
Balance with Interest:
principal + monthly_interest -
Remaining Balance:
balance_with_interest - monthly_payment
Example: Loan Balance Calculator
This program calculates the remaining balance after the first two installments −
Note: This program requires user input. When running online, provide sample values: Loan Amount: 45000, Interest Rate: 7, Monthly Payment: 1000
#include <stdio.h>
int main() {
float loanamt, interest, monthlypayment;
float monthly_interest, balance_with_interest, firstmon, secondmon;
printf("Enter the loan amount: ");
scanf("%f", &loanamt);
printf("Enter interest rate (annual %%): ");
scanf("%f", &interest);
printf("Enter monthly payment: ");
scanf("%f", &monthlypayment);
/* Calculate first month balance */
monthly_interest = loanamt * ((interest / 100) / 12);
balance_with_interest = loanamt + monthly_interest;
firstmon = balance_with_interest - monthlypayment;
/* Calculate second month balance */
monthly_interest = firstmon * ((interest / 100) / 12);
balance_with_interest = firstmon + monthly_interest;
secondmon = balance_with_interest - monthlypayment;
printf("\nLoan Details:
");
printf("Original loan amount: %.2f
", loanamt);
printf("Annual interest rate: %.2f%%
", interest);
printf("Monthly payment: %.2f
", monthlypayment);
printf("\nRemaining amount after 1st installment: %.2f
", firstmon);
printf("Remaining amount after 2nd installment: %.2f
", secondmon);
return 0;
}
Enter the loan amount: 45000 Enter interest rate (annual %): 7 Enter monthly payment: 1000 Loan Details: Original loan amount: 45000.00 Annual interest rate: 7.00% Monthly payment: 1000.00 Remaining amount after 1st installment: 44262.50 Remaining amount after 2nd installment: 43520.70
How It Works
The program follows these steps for each month −
- Calculate monthly interest: Apply the annual interest rate divided by 12 to the current balance
- Add interest to principal: The new balance includes the accumulated interest
- Subtract payment: Deduct the monthly payment from the balance with interest
- Repeat: Use the remaining balance as the principal for the next month
Key Points
- Interest is calculated monthly as
(annual_rate / 100) / 12 - Each month's balance becomes the principal for the next month's interest calculation
- The program assumes fixed monthly payments and compound interest
Conclusion
This C program effectively calculates loan balance installments by applying monthly compound interest and deducting fixed payments. It provides a foundation for more complex loan amortization calculations.
