Regarding square root basic approach program

why we use float in this program?

Hi @shlok.sharma3,
we declare answer as float since if it was declared integer, integer + .1=integer i.e we wont be able to add float number to integer i.e we wont be able to add inc when its value is <1 i.e (inc<1).
eg. find root of 10.
first ans=3, inc=1.
then ans=3.1, inc=.1 (if ans was integer, it would have still remained 3)
Hope dis helps.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.