🚀Beginner

Find Compound Interest

Calculate compound interest

Compound Interest (CI) is interest calculated on both the initial principal and the accumulated interest from previous periods. It's called "interest on interest" and grows faster than simple interest.

📐 Formula

A = P × (1 + R/100)T
CI = A - P

A

Final Amount

P

Principal

R

Rate (%)

T

Time (years)

📊 Simple vs Compound Interest (₹10,000 at 5% for 2 years)

Simple Interest

₹1,000

Compound Interest

₹1,025

C Program to Calculate Compound Interest

compound_interest.c
C
1#include <stdio.h>
2#include <math.h> // For pow() function
3
4int main() {
5 float principal, rate, time, amount, ci;
6
7 // Input values
8 printf("Enter Principal: ");
9 scanf("%f", &principal);
10
11 printf("Enter Rate (%%): ");
12 scanf("%f", &rate);
13
14 printf("Enter Time (years): ");
15 scanf("%f", &time);
16
17 // Calculate: A = P × (1 + R/100)^T
18 amount = principal * pow(1 + rate/100, time);
19
20 // Compound Interest = Amount - Principal
21 ci = amount - principal;
22
23 printf("\nCompound Interest = %.2f\n", ci);
24 printf("Total Amount = %.2f\n", amount);
25
26 return 0;
27}
Output

Enter Principal: 10000

Enter Rate (%): 5

Enter Time (years): 2

 

Compound Interest = 1025.00

Total Amount = 11025.00

📖 Code Explanation

CodeExplanation
#include <math.h>Required for pow() function
pow(base, exp)Calculates base raised to power exp
1 + rate/100Convert percentage to decimal multiplier
ci = amount - principalCI is the extra money earned

⚠️ Compilation Note

When using <math.h>, link the math library:
gcc program.c -lm -o program

🎯 Key Takeaways

A = P × (1 + R/100)T
CI = A - P (Amount - Principal)
pow() from math.h for exponents
CI > SI for same values

Want to Learn More?

Explore our comprehensive tutorials for in-depth explanations of C programming concepts.

Browse Tutorials
Back to All Examples