Write a program to compute simple interest and compound interest
Answers
Answer:
A program to compute simple interest and compound interest.
Explanation:
C program to calculate simple interest:-
#include<stdio.h>
int main() {
int p,r,t,SI;
printf("Enter Principle, rate and time\n");
scanf("%d%d%d",&p,&r,&t);
SI = (p * r * t)/100; /*Formula for calculating simple interest*/
printf("Simple interest of %d, %d and %d is %d\n",p,r,t,SI);
return 0;
}
Output:-
Enter Principle, rate and time
1000
4
5
Simple interest of 1000, 4 and 5 is 200
C program to calculate compound interest:-
#include<stdio.h>
int main() {
float p,r,t,CI;
printf("Enter Principle, rate and time\n");
scanf("%f%f%f",&p,&r,&t);
CI = p*pow((1+r/100),t); /*Formula for calculating Compound Interest*/
printf("Compound interest of %f, %f and %f is %f\n",p,r,t,CI);
return 0;
}
Output:-
Enter Principle, rate and time
1000
4
5
Compound interest of 1000.000000, 4.000000 and 5.000000 is 1216.652710