using variable in the "pow" function

I'm trying to figure out what is wrong with this:

static_cast<int>((pow(x, counter+1)) % 10)

it says "more than one instance of overloaded function "pow" matches the argument list"
closed account (1CfG1hU5)
the format looks okay. from what I found on this web page:

http://www.cplusplus.com/doc/tutorial/typecasting/

what are your x and counter vars declarations/assigns? can you paste more?

trying to get an idea of what the remainder of the pow function divided by 10 is.

What are types of x and counter?

Also you have extra closing bracket in the end. I assume it's related to the first (unshown) part of your expression.
closed account (1CfG1hU5)
static_cast<int>(pow(x, counter+1) % 10) may be enough.

didn't think to contest a set of ()
static_cast<int>(pow(x, counter+1) % 10) may be enough.
It is not. Inner statement is pow(x, counter+1) % 10 and % operator cannot be applied to floating point value returned by pow. So OP had it right: converting result of pow() to int, then calculating modulus.
closed account (1CfG1hU5)
k
Topic archived. No new replies allowed.