Subscribe Us

Responsive Advertisement

Advertisement

Squre root of a given number without sqrt function

 Squre root of a given number without sqrt function

by ujjal roy



long long int floorSqrt(long long int x) 

{

    // Your code goes here   

    long long int r,i,ans;

    if(x==0||x==1)return x;

    else

    {

        ans=1,i=1;

        for(i=1;ans<=x;i++)

        {

            ans=i*i;

        }

    }

    return (i-2);

}

Post a Comment

0 Comments