I cannot figure out how to write this equation into a program.
P = Ar /( 1 - (1 + r) to the negative n power)
This is a discussion on I can't figure this out! within the C++ Programming forums, part of the General Programming Boards category; I cannot figure out how to write this equation into a program. P = Ar /( 1 - (1 + ...
I cannot figure out how to write this equation into a program.
P = Ar /( 1 - (1 + r) to the negative n power)
Try pow ( declaration in <math.h> ).
pow
Calculates x raised to the power of y.
double pow( double x, double y );
I think you code would look something like this.
P = Ar / pow( ( 1 - ( 1 + r ) ), -n );
Last edited by Dang; 09-19-2001 at 10:21 PM.
Hi
you know from math cources that X^-n is euqal to 1/X^n so try to use thet and rewrite your code usin the positive powers
e.g.
P = Ar /( 1 - 1/pow((1 + r),n)) where n is with the oposite sign from your original post
damyan