Pow!

A couple of nights back whilst revising for my math GCSE, I flicked through the beggining of a book I had when I reached interests.

I thought I'd create a program that finds out the compund interest of something for x amount of years, but the pow() operator(?) doesn't accept variables.

I was just wondering if there was any way around this.
pow is a function, not an operator. You need to #include <cmath> for it.


http://cplusplus.com/reference/clibrary/cmath/pow/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
double pow ( double base, double exponent );
long double pow ( long double base, long double exponent );
float pow ( float base, float exponent );
double pow ( double base, int exponent );
long double pow ( long double base, int exponent );

template<class T> complex<T> pow (const complex<T>& x, int y);
template<class T> complex<T> pow (const complex<T>& x, const complex<T>& y);
template<class T> complex<T> pow (const complex<T>& x, const T& y);
template<class T> complex<T> pow (const T& x, const complex<T>& y);

template<class T> valarray<T> pow (const valarray<T>& x, const valarray<T>& y);
template<class T> valarray<T> pow (const valarray<T>& x, const T& y);
template<class T> valarray<T> pow (const T& x, const valarray<T>& y);
¿what are you talking about?
pow is a function, ¿how are you calling it?
Well, I was doing something along the lines of:

pow(interestrate/100,3)

Unfortunately, that doesn't work, I was wondering if there was any way around that problem.

(It doesn't really matter if there isn't, it was just annoying)
It does work fine. You are just doing something wrong.
writing 3.0 instead of 3 may fix your "problem" though if interestrate is an integer.
Last edited on
Is interestrate an int or double?

Make sure to use () around that expression. See if it fixes your problem.
Ah, it's fixed now. Thank you!
Topic archived. No new replies allowed.