Square Root Problem

So i was watching the lecture on how to find square root of a number, and i tried to write the code a little differently from what was taught in the video. Although the code seems to run fine, i think there is some error. Since i can’t locate it, i need help. I have written my code below.

#include
using namespace std;

int main()
{
int N;
float n = 0;
float x = 1.0;
float P;
cout<<"Enter the number whose square root is to be found: ";
cin>>N;
cout<<"Enter the precison P: “;
cin>>P;
for(; P<=x; x = x/10)
{
for(; n*n<=N; n = n + x)
{}
n = n - x;
}
cout<<n<<” is the approximate square root of "<<N;
return 0;
}

hello @priyam04

pls save ur code here->


and share its link with me

here is the link : https://ide.codingblocks.com/s/446394

check now->

When i am clicking on the link, it says forbidden.

okay so i saw the update you have made, but what is the problem in comparing P with x…is it that both variables are changing that’s why we should not compare them?

yeah . . . . . . .
they both are changing , and they are not direclty related

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.