-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path14_compound_interest.c
32 lines (26 loc) · 1010 Bytes
/
14_compound_interest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// // C program calculate Compound Interest
// // Header Files
#include <stdio.h>
#include <conio.h>
#include <math.h>
// // Main Function Start
int main()
{
double principalAmount, rateOfInterest, time, totalAmount, compoundInterest, compoundedAfterMonths;
printf("\nEnter Pricipal Amount => ");
scanf("%lf", &principalAmount);
printf("\nEnter Rate of Interest => ");
scanf("%lf", &rateOfInterest);
printf("\nEnter Time => ");
scanf("%lf", &time);
printf("\nCompounded After Every N Months => ");
scanf("%lf", &compoundedAfterMonths);
double n = 12 / compoundedAfterMonths; // // Get Compounded Interval (such as Monthly, Quarterly,Half-yearly,Yearly etc.)
totalAmount = principalAmount * pow((1 + rateOfInterest / (100 * n)), n * time);
compoundInterest = totalAmount - principalAmount;
printf("\nCompound Interest => %.2lf", compoundInterest);
printf("\nTotal Amount => %.2lf", totalAmount);
getch();
return 0;
}
// // Main Function End