Compound interest
#include <stdio.h>
#include <math.h>
int main() {
double principal, rate, time, amount, compoundInterest;
printf("Enter the principal amount: ");
scanf("%lf", &principal);
printf("Enter the interest rate (%): ");
scanf("%lf", &rate);
printf("Enter the time period (years): ");
scanf("%lf", &time);
// Calculate compound interest
amount = principal * pow(1 + rate / 100, time);
compoundInterest = amount - principal;
printf("Compound Interest: %.2lf\n", compoundInterest);
return 0;
}
Comments
Post a Comment