C Programs | IT Developer
IT Developer

C Programs



Share with a Friend

Loan Amortization Table Program in C

Introduction

In loan repayment, each EMI consists of:

  • Interest Part = Current Balance × Monthly Interest Rate
  • Principal Part = EMI – Interest Part
  • New Balance = Old Balance – Principal Part

We’ll generate a month-wise table until the loan is fully repaid.

 

C Program: Loan Amortization Table

C

#include <stdio.h>

#include <math.h>   // for pow()

 

int main() {

    float principal, rate, emi, monthlyRate, interest, principalPart, balance;

    int time, months, i;

 

    // Input loan details

    printf("Enter loan amount (Principal): ");

    scanf("%f", &principal);

 

    printf("Enter annual interest rate (in %%): ");

    scanf("%f", &rate);

 

    printf("Enter tenure (in years): ");

    scanf("%d", &time);

 

    // Convert values

    months = time * 12;

    monthlyRate = rate / (12 * 100);  // monthly interest rate

 

    // EMI formula

    emi = (principal * monthlyRate * pow(1 + monthlyRate, months)) /

          (pow(1 + monthlyRate, months) - 1);

 

    // Initialize balance

    balance = principal;

 

    // Print table header

    printf("\n==============================================\n");

    printf(" Month |   EMI   | Interest | Principal | Balance\n");

    printf("==============================================\n");

 

    // Loop for each month

    for (i = 1; i <= months; i++) {

        interest = balance * monthlyRate;

        principalPart = emi - interest;

        balance -= principalPart;

 

        if (balance < 0) balance = 0; // avoid negative due to precision

 

        printf(" %5d | %7.2f | %8.2f | %9.2f | %8.2f\n",

               i, emi, interest, principalPart, balance);

    }

 

    printf("==============================================\n");

 

    return 0;

}

Output

 
OUTPUT :
Enter loan amount (Principal): 100000
Enter annual interest rate (in %): 12
Enter tenure (in years): 1

==============================================
 Month |   EMI   | Interest | Principal | Balance
==============================================
     1 |  8884.88 | 1000.00 |   7884.88 | 92115.12
     2 |  8884.88 |  921.15 |   7963.73 | 84151.39
     3 |  8884.88 |  841.51 |   8043.37 | 76108.02
     4 |  8884.88 |  761.08 |   8123.80 | 67984.22
     5 |  8884.88 |  679.84 |   8205.04 | 59779.18
     6 |  8884.88 |  597.79 |   8287.09 | 51492.09
     7 |  8884.88 |  514.92 |   8369.96 | 43122.13
     8 |  8884.88 |  431.22 |   8453.66 | 34668.47
     9 |  8884.88 |  346.68 |   8538.20 | 26130.27
    10 |  8884.88 |  261.30 |   8623.58 | 17506.69
    11 |  8884.88 |  175.07 |   8709.81 |  8796.87
    12 |  8884.88 |   87.97 |   8796.91 |     0.00
==============================================

Explanation

  1. User enters loan amount, annual interest rate, and tenure.
  2. EMI is calculated using the formula.
  3. Each month:
    • Interest = Current Balance × Monthly Rate
    • Principal Part = EMI – Interest
    • Balance = Balance – Principal Part
  4. The loop continues until all months are complete.
  5. The table displays month-by-month breakdown.