Here is my code for finding the square root, pls help me in finding the error in it.
include iostream>
using namespace std;
int main()
{
float n;
cin >>n;
int p;
long double l = 0.1;
cin>>p;
int x = 0;
float y = 0;
for ( int i = 1; i<= n; i++)
{
if ( i * i <= n)
{
x+=1;
}
else if ( i * i >= n)
{
break;
}
}
for ( int a = 1; a<=p; a++ )
{
for ( float j = l; j<=10*l; j+=l)
{
if( (x+y+j)*(x+y+j) <= n )
{
y+=l;
}
else if ( (x+y+j)*(x+y+j) > n )
{
break;
}
}
l = l*0.1;
}
cout<<x+y<<endl;
return 0;
}