Compound interest formula coding

Im having problems coding this
A = P(1 + r/n)nt
1
2
3
4
5
6
7
8
9
10
11
12
13

//Declared test cases
    float principal = 200000.00, annualInt = 0.03;
    float years = 10.0;

float calcInterest1(float principal, float years, float annualInt)
{
    float interest1;
    float nt = annualInt*12;
    float A = principal+annualInt;//Accrued Amount
    interest1 = (A = (principal*(1+years/100))pow(nt));// A = P(1 + r/n)nt
    return interest1;
}
You don't need

A = ...

again when calculating the interest.
Topic archived. No new replies allowed.