Compound Interest Formula

Description: Takes the principle amount, interest rate, number of compoundings per year and the number of years. Returns the total value after N years.
Tested Platform: Visual Studio 64-bit, Windows 10
Language: C++
// 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