whst is the meaning of output -nan?

Try avoiding squaring huge terms (like some values may be 10^18 and if u square it then it becomes 10^36 and it may get u -nan)

Cuz u must have done sqrt of that numberâ€¦ and sqrt of negative number is not possibleâ€¦

-nan means NotANumber(because if a number exceeds max limit then it will become negative)

Try using long doubleâ€¦ Avoid calculations where u need to square values which are high enough and check if a value is not negative before before doing sqrtâ€¦check if there is any alternate for squaring a huge number

PS: this is soln to avoid -nan according to what I have experiencedâ€¦

The word NaN stands for Not a numberâ€¦

It usually occur whenevr we have used the value which is undefined.

For eg. The square root of a negative number is undefined and hence it will give the NaN as output

Similarly if you take the log of the negative number it will give you NaN as output.

Hope it will help.