#include <codecogs/finance/accounting/xnpv.h>
using namespace Finance::Accounting;
| double | xnpv (double rate, double values[], int dates[], int nV) Calculate net present value for a series of non-periodic cash flows.
Excel: XNPV |
| doublexnpv( | double | rate | |
| double* | values | ||
| int* | dates | ||
| int | nV | ) |

#include <iostream> #include <codecogs/finance/accounting/xnpv.h> int main(int argc, char *argv[]) { double pmts[]={-10000, 2750, 4250, 3250, 2750}; int dates[]={34334,34393,34636,34744,34789}; std::cout<<"Net present value: "; std::cout<<Finance::Accounting::xnpv(0.09, pmts, dates, 5); std::cout<<std::endl; return 0; }Output:
Net present value: 2089.5| rate | The discount rate to apply to the cash flows. For 9% use a rate of 0.09 . |
| values | An array of cash flows that correspond to a series of payments on specific dates. |
| dates | An array of dates on which the corresponding payments are made. |
| nV |