+ 8

Why is 5^3 = 124 in the following code snippet and how do we correct the error?

int a=15%10; int b=pow(a,3); cout<<b;

17th May 2017, 8:29 AM
Sheena Singh
Sheena Singh - avatar
5 Answers
+ 12
Declare b as float or double, pow() function returns double value.
17th May 2017, 9:22 AM
Shamima Yasmin
Shamima Yasmin - avatar
+ 10
@Antony, same here! â˜ș
4th Jun 2017, 8:09 AM
Sheena Singh
Sheena Singh - avatar
+ 9
Thanks for your help :)
17th May 2017, 9:26 AM
Sheena Singh
Sheena Singh - avatar
+ 4
or dont use pow
17th May 2017, 9:23 AM
jay
jay - avatar
0
why are we getting wrong for 5 powers only when we use pow(5, )?
4th Jun 2017, 9:08 AM
vinay kumar
vinay kumar - avatar