Compute simple and compound interest for a principal of 50000 at 8% for 3 years.
Solution
main.c
#include <math.h>
#include <stdio.h>
int main(void) {
double p = 50000, r = 8, t = 3;
double si = p * r * t / 100;
double ci = p * pow(1 + r / 100, t) - p;
printf("simple %.2f, compound %.2f\n", si, ci);
return 0;
}
Output Verified by compiling and running
simple 12000.00, compound 12985.60
SI = PRT/100; CI = P(1 + R/100)ᵀ − P. r / 100 is floating-point division because r is a double. Compound interest earns interest on interest, hence the higher value.
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!
We use Google Analytics cookies to see how LearnFrenzy is used and make it better, and Google AdSense to keep it free.
No analytics or ad cookies are set until you accept. Privacy Policy
·
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!