How to Use C Language to Calculate Compound Interest
- 1). Open a text editor or C Integrated Development Environment (IDE). Windows Notepad will do if you have nothing else.
- 2). Type the following C program:
#include <stdio.h>
#include <math.h>
double principal = 100;
double interestRate = 0.1;
double periods = 5;
double futureValue;
int main() {
futureValue = principal * pow((1 + interestRate), periods);
printf("The future value will be: %3.2f.", futureValue);
} - 3). Modify the principal, interest rate, and interest periods (normally years) to use in the computation.
- 4). Save your work.
Source...