// Returns the total value of the principle after N years
double compoundInterest(double principle, double interestRate, int compoundingsPerYear, int years) {
double adjustedInterest = interestRate / 100.0;
return principle * pow((1.0 + (adjustedInterest / compoundingsPerYear)), compoundingsPerYear * years);
}
Posted: March 20, 2023
Return to the snippets listing