Compound interest program in c is a simple program to implement in c
In this tutorial we will learn what is mean by compound interest , how to calculate compound interest, compound interest formula, and c program to find compound interest, compound interest problems.
Finding compound interest is very easy same as c program to find simple interest.
Let’s see first introduction to compound interest
Compound interest definition ?
Lets see what is compound interest –
Compound interest is calculated on initial the principal amount and also interest on investment of previous periods of loan.
The value compound is reinvesting the interest, rather paying it out.
Compound interest formula –
Lets see compound interest formula
Compound interest = Principal((1+rate/n)^(n*time))
Where principal is principal amount to be invested
Rate is a rate of interest
N is no of days amount investment
Times is number of time compounded
Principal = 5000
Rate = 5
No of year = 10
Times = 12
now calculate compound interest
Compound interest =Principal((1+rate/n)^(n*time))
Compound interest = 8235.04
Logic to calculate compound interest in c programming :
First we take a input principal, rate, no of years, and times from user and using compound interest formula we calculate compound interest and print the result.
Algorithm to calculate compound interest
2. Declare variables
3. Take a inputs from user principal, rate, no, and times
4. Calculate compound interest using formula.
5. Print Compound interest
C program to find compound interest
printf("Enter rate in percentage\n");
printf("Enter time in years(demcimals)\n");
printf("Enter number of times interest is compounded per year\n");
printf("Compound Interest is %f\n",compoundInterest);
1. First statement in c program we include a header files.
2. Next write a main function .
3. Declare variables
compoundInterest => to store compound interest
principal => to store principal amount
rate => to store rate of interest
time => to store no of years for compound interest
n => to store a no of times interest compounded
4. Next take a input from user a values for principal, rate, no of years and no times interest compounded.
printf(“Enter rate in percentage\n”);
printf(“Enter time in years(demcimals)\n”);
printf(“Enter number of times interest is compounded per year\n”);
5. Example :-
Suppose user inputs
principal = 5000
rate = 5
time = 10
n = 12
6. Next using formula calculate compound interest
This is a simple way to write a expression in c programming.
compoundInterest = 8235.047852
7. Next print the compound interest that we calculated using formula.
printf(“Compound Interest is %f\n”,compoundInterest);
=> Compound Interest is 8234.047852