Error in my approach for finding square root

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;

}

hello @vector.9974
a)pls share ur code using cb ide.

b) also pls tell me what issue u r facing, if u r submitting it somehwere then share its link with me

how can i share using cb ide, is there any provision

@vector.9974
go to this link ->https://ide.codingblocks.com/
paste ur code .
press ctrl + s
a link will be generated in ur search tab, share that link with me

sir, the problem is in the precision part. When i cross check the answer generated via this code and via a calculator i find different answers for the precision part

@vector.9974
i think u have shared some wrong link .pls check

@vector.9974


a)use double
b) formula should be (x+y+ l ) * (x+y+l) || u were using j in place of l

thanks a lot sir…