Hello All,
I have this statement in my code:
for (counter = 0; counter <= 2; counter++)
{
runner = (temp_value % 10);
temp_value = temp_value / 10;
return_value = return_value + (runner * (10 ^ counter));
}
When I run this (10 ^ counter), counter = 0, so I am expecting an asnwer of 1, but the returned value is 10.
What am I missing? If anyone know, please guide me.
Regards
Rob
I like to make a small function of my own for these positive integer power operations. (VS2010 doesn't have a
int pow(int, int)
function in <cmath>:
1 2 3 4 5 6 7
|
int pow (int base, int exp)
{
int output = 1;
while (exp--)
output *= base;
return output;
}
|
Last edited on