+ 1

Floating point exception

if "num" is any 5 digit integer number "sum" is in integer. then sum =0; for(int i=1;i<=5;i++) { sum = sum + num%pow(10,i); num = num/10; } I'm getting Run time error i.e., "floating point exception" Please explain me the reason.

27th Jan 2018, 3:59 AM
Nikhar Sachdeva
Nikhar Sachdeva - avatar
3 Answers
0
Yes.I was trying to reverse the number.. I did it with 3 statements in loop..But I was just trying it too and thought it'll work.. I'll try your method too.. Thank You
28th Jan 2018, 12:10 PM
Nikhar Sachdeva
Nikhar Sachdeva - avatar