Unable to understand the logic!

Totally confused in logic part that is , in that nested loop part , please clear it sir

hello @piyushkumar999999

the inner loop is for precision, in that loop we keep adding inc (which is 1 initaillly) to our ans till ans*ans <=n and
in next interation we are dividing our inc by 10 that now inc is 0.1 , and repeating the same procedure again. we are doing this procedure p times to get square root upto p digit precision

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.

The above code is quite basic
Say we have precision 1 then
Say we have to find sqrt of 10
Then we check 1*1<=10 increment
2*2<=10 we increment
3*3<=10 we increment
Now 4*4>10 so we stop for current p=0 and do ans-precision
now p=1 so we divide 1 by 10 which is 0.1
So
3.1*3.1=9.61
3.2*3.2=10.24 which is greater than 10
so we do 3.2-0.1 =3.1 and we stop for p=1

Hence ans =3.1