#include<stdio.h>
#include<math.h>
int main() {
float CompoundInterest, rate, time, principal, n, amount;
/*
1. Take Input from User
principal amount, rate(%), n(per yr), time(in yrs)
n = no. of times interest compounded per year
*/
rate = rate /100;
amount = principal * pow((1+r/n), n*time);
CompoundInterest = amount-principal;
/*
2. Display the Result
printf("The Total Amount: %.2f\n", amount);
printf("The Compound Interest %.2f\n", CompoundInterest);
*/
return 0;
}
CODE TESTED and RAN!
Update:-
- Reduced complexity, confusion.
- Made it understandable & readable.
Mistakes:-
- Made it understandable & readable.
Mistakes:-
- don't forget to put comma "," after pow here's an example:-
principal * pow(1+r/n),n*time);
No comments:
Post a Comment