I just recently started learning C++ and I'm trying to write my first basic program. I decided to make one that would calculate the future value of an annuity when the user enters the present value, interest rate, and time.
Here's the code for the program. (I couldn't put the whole code, so I stripped out all the couts and cins.) The problem is in the 8th line with text in it. I need to make FV = PV * (1 + interest)^months. For some reason I can't use the ^ symbol for exponents.
#include %26lt;iostream%26gt;
using namespace std;
int main()
{
string exit;
typedef float f;
f PV, interest, months, FV;
FV = PV * (1 + interest)
cout %26lt;%26lt; "The future value of your deposit will be: $" %26lt;%26lt; FV %26lt;%26lt;endl;
cin%26gt;%26gt;exit;
return 0;
}
Exponents in C++?
use the math.h library
pow()
Reply:use: f(x)pow(exponent)
Reply:you us math or you do it manually
base, more ,x,y as int
base= 1000$
more= 1000 depot each year
x= 1,065
y=10 years
i=0;
base = base * x
for (i%26lt;y;i++)
{
base = base + more
base * x
}
look like that have fun
if you dont use labrary it take less place and it will run faster
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment