# Calculate Compound Interest C Program

## C Program To Calculate Compound Interest

Learn How To Write A Program To Calculate Compound Interest in C Programming Language. This C Program To Find Compound Interest takes in values of Principal Amount, ROI and Time Period from the User.

#### What is Compound Interest?

Compound Interest is the interest computed on the initial principal amount and also on the accumulated interest of previous periods of a deposit or a loan.

**Must Read: C Program To Find Simple Interest using Functions**

#### C Program To Find Compound Interest without Function

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include<stdio.h> #include<math.h> int main() { float principal, rate_of_interest, time_period, compound_interest; printf("\nEnter The Principal Amount:\t"); scanf("%f", &principal); printf("\nEnter The Interest Rate:\t"); scanf("%f", &rate_of_interest); printf("\nEnter The Time Period in Years:\t"); scanf("%f", &time_period); compound_interest = principal * (pow((1 + rate_of_interest/100), time_period) - 1); printf("\nCompound Interest:\t%f\n", compound_interest); return 0; } |

#### Calculate Compound Interest in C Programming using Function

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include<stdio.h> #include<math.h> float compound_interest(float p, float r, float n) { float interest; interest = p*(pow((1 + r/100), n) - 1); return interest; } int main() { float principal, rate_of_interest, time_period, result; printf("\nEnter The Principal Amount:\t"); scanf("%f", &principal); printf("\nEnter The Interest Rate:\t"); scanf("%f", &rate_of_interest); printf("\nEnter The Time Period in Years:\t"); scanf("%f", &time_period); result = compound_interest(principal, rate_of_interest, time_period); printf("\nCompound Interest:\t%f\n", result); return 0; } |

**Must Read: C Program To Find LCM of Two Numbers**

#### Output

If you have any doubts or compilation errors in this C Program To Compute Compound Interest, let us know about it in the Comment Section below.

Thanks for this awesome code. But, when I try this Compound Interest C Program in Windows, it works fine. But, in Linux it gives an errof regarding the pow() method. Please help.

Execute it using this command:

gcc testprogram.c -lm

Amazingly simple program for compound interest. Thanks