I'll guarantee that, if you're doing interest rate calculations (or anything else requiring floating point accuracy), you should not be using an int
data type.
In addition ^
is not the power operator, it's the exclusive-or operator. You need to look into the pow
standard library function.
That should hopefully be enough for you to figure out why your homework is misbehaving, without me doing all the work for you.
Aside: The construct
cout<<"Interest Rate", cout<<R;
is a pretty rare one. It may work (I don't know off the top of my head whether the comma operator is a sequence point and I'm too lazy to go look it up at the moment), but you should probably prefer something like the more usual:
cout << "Interest Rate: " << R << endl;
And you probably want to output A
(the answer) at some point :-)