d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Error Messages
Add Reply New Topic New Poll
Member
Posts: 18,191
Joined: May 31 2010
Gold: 149.27
Sep 27 2014 10:34am
Code
// Kolten Minix - Co127 - 9/27/10
#include <iostream>
#include <cmath>
#include "compfun.h"
using namespace std;


double futureValue(double presentValue, double rate, int n){
presentValue * (1, rate) ^ n;
}

int main() {
decimals(cout, 2);
// Test
cout << futureValue(1000.00, 7.5 / 1200.0, 36) << endl;

}


it wont let me compile it due to this error:

Error 2 error C2296: '^' : illegal, left operand has type 'double'
3 IntelliSense: expression must have integral or unscoped enum type

I tried looking it up on stack overflow, but coulndnt find a problem that was similar to mine

Member
Posts: 6,192
Joined: Dec 13 2010
Gold: 6,669.99
Sep 27 2014 11:10am
You're not returning anything in your futureValue function and ^ is a xor, not power

e: what are you trying to do here?
presentValue * (1, rate) ^ n;

This post was edited by ShadowFiend on Sep 27 2014 11:14am
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Sep 27 2014 01:11pm
Quote (ShadowFiend @ Sep 27 2014 01:10pm)
You're not returning anything in your futureValue function and ^ is a xor, not power

e: what are you trying to do here?
presentValue * (1, rate) ^ n;


Expanding on this, if you wanted to get the power you need to include "math" and use the pow() function.
Member
Posts: 18,191
Joined: May 31 2010
Gold: 149.27
Sep 28 2014 11:01am
Quote (ShadowFiend @ Sep 27 2014 01:10pm)
You're not returning anything in your futureValue function and ^ is a xor, not power

e: what are you trying to do here?
presentValue * (1, rate) ^ n;


Quote (AbDuCt @ Sep 27 2014 03:11pm)
Expanding on this, if you wanted to get the power you need to include "math" and use the pow() function.


Yes I figured out that thats not a correct operator to the power of n
i had to change my code to
return presentValue * pow((1+rate), n);
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll