C Program to Calculate Simple interest and Compound interest
In today’s post, we will make a program in c to calculate Simple Interest and Compound Interest
But before that, we know what is Simple Interest and Compound Interest and how to get it out.
Introduction to simple interest and compound interest
Simple Interest and Compound Interest is a way to calculate the interest on the loan taken by you. Simple interest is calculated on the principal amount, this formula is used to calculate the simple interest.
S.I = (P * R * T) / 100 where P = Principal, R = Rate and T = Time
Compound interest is calculated on the principal amount plus that interest. This formula is used to calculate compound interest.
CI = P(1 + r / n)nt where P = Principal, R = Rate, n = number of compounding periods per unit and T = Time.
C Program to Calculate Simple interest
Algorithm -:
- Program start.
- Declaration of variable with their data type, like :- int P, R, T; float I;
- Input the value in variable
- Arithmetic operator used to perform SI=(p*r*t)/100;
- printf( ) called to print value of variable
- Program end.
Flowchart -:
Program For Simple Interest
#include<stdio.h>
void main()
{
int p,r,t;
float i;
printf("Enter the Principal, Rate and Time\n");
scanf("%d %d %d",&p,&r,&t);
/*Formula for calculating simple interest*/
i=p*r*t/100;
printf("simple interest is : %f",i);
}
Output -:
Enter the Principal, Rate and Time
1000
7
8
simple interest is : 560.00000
C Program to Calculate Coumpound interest
Algorithm
- Program start.
- Declaration of variable with their data type, like :- int p, r, t,CI; float I;
- Input the value in variable
- CI = p*pow((1+r/100),t);
- printf( ) called to print value of CI
- Program end.
Program for Compound Interest
#include<stdio.h>
#include<math.h>
int main()
{
float p,r,t,CI;
printf("Enter Principle, rate and time\n");
scanf("%f%f%f",&p,&r,&t);
/*Formula for calculating
Compound Interest
*/
CI = p*pow((1+r/100),t);
printf("Compound interest is : %f\n", CI);
return 0;
}
Output -:
Enter Principle, rate and time
1000
7
8
Compound interest is : 1718.186890
C Program For simple interest and Compound interest
Algorithm
- Program start.
- Declaration of variable with their data type, like :- int p, r, t,i, CI; float
- Input the value in variable
- i=p*r*t/100;
- CI = p*pow((1+r/100),t);
- printf( ) called to print value of i and CI
- Program end.
#include<stdio.h>
#include<math.h>
int main()
{
int p,i,t;
float r,CI;
printf("Enter Principle, rate and time\n");
scanf("%d%f%d",&p,&r,&t);
/*Formula for calculating Compound Interest */
i=p*r*t/100;
/*Formula for calculating Compound Interest*/
CI = p*pow((1+r/100),t);
printf("simple interest is : %d",i);
printf("Compound interest is : %f\n", CI);
return 0;
}
Output
Enter Principle, rate and time
1000
7
8
simple interest is : 560.000000
Compound interest is : 1718.186890
Read More
- Download C Language Notes Pdf
- C Language Tutorial For Beginners
- C Programming Examples With Output
- 250+ C Programs for Practice PDF Free Download
Conclusion
Friends, If you have difficulty to understand any program or have any doubts or questions, then tell me in the comment below.