calculating compound interest

I'm just learning C++ and need some help with formatting a proper calculation to get a compounded interest using an exponent. I'm basing my formula on
P*(1+rate/t)^t but getting errors and the wrong output.


#include <iostream>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <math.h>

using namespace std;

int main()

{

cout<<"\n\n\t\tSavings Account Balance\n";
cout<<"n\t\tEnter the following:";

float interestRate;
int compound;
float principal;
float interest;
float balance;

cout<<"\n\n\n\n\t\tYour principal amount: $";
cin>>principal;

cout<<"\n\t\tNumber of times compunded annually: ";
cin>>compound;

cout<<"\n\t\tInterest Rate: ";
cin>>interestRate;
interestRate=interestRate/100;


balance=principal*(1+interestRate/12)^12;

essentially I want the calculation to be 1000*(1+0.0425/12)^12

Any suggestions?
Found the answer if any other newbies needed it.

using the POW function: balance=principal*pow(1+interestRate/12,12);
Thats a good one, the pow function from the <cmath> header should help you implement the compound interest formula.

I however have a similar challenge that requires the use of a loop structure to calculate the compound interest of initial investment 2600 at an annual interest rate of 5%, you should assume the interest is paid annually for 10 years.
Thanks. I changed my header to the <cmath> works good.
Topic archived. No new replies allowed.