Search⌘ K

Example 33: Calculate Interest

Explore how to implement a compound interest calculation in C by taking inputs for principal, interest rate, number of years, and compounding frequency. Learn to apply loops in this financial calculation and understand the formula to compute the final amount effectively.

We'll cover the following...

Problem

When interest compounds q times per year at an annual rate of r% for n years, the principal p compounds to an amount a as per the following formula:

a=p(1+rq100)nqa=p(1+ \frac{{r}}{q * 100})^{nq}
...