#include <codecogs/finance/accounting/pv.h>
using namespace Finance::Accounting;
| double | pv (double rate, int n, double p, double vn, PaymentPoint when=pp_EndOfPeriod) Return the present value of an investment. |
| doublepv( | double | rate | |
| int | n | ||
| double | p | ||
| double | vn | ||
| PaymentPoint | when = pp_EndOfPeriod | ) |
Further information available when you purchase a licence.
The code also uses an enumerated type PaymentPoint, using the following values:#include <stdio.h> #include <codecogs/finance/accounting/pv.h> int main(int argc, char *argv[]) { double d = Finance::Accounting::pv(0.06, 20, 500000, 0, Finance::Accounts::pp_EndOfPeriod); printf("The present value of the $10 million prize is: %7.2f\n", d); return 0; }Output:
The present value of the $10 million prize is: 5734960.61
| rate | is the interest rate - assumed constant. |
| n | is the number of periods over which to calculate. |
| p | are the payouts from the investment made either at the start or end of each period (as defined by when). |
| vn | The future value of the investment. |
| when | The point in each period when the payment is made, either pp_StartOfPeriod or pp_EndOfPeriod. |