Loop - Square Root

Ans not showing after compilation of code. Plz check for any mistakes.

#include
using namespace std;
int main() {

float n,p;
cin>>n>>p;

float ans = 0;
float inc = 1;

float times = 0;      // p+1 times for p places
while(times<=p);{

while(ans*ans <=n){
    ans = ans + inc;
}
ans = ans - inc;
inc = inc / 10;
times = times + 1;
}
cout <<ans<< '\n';

return 0;
}

Your program is facing TLE (Time Limit Exceed) even for a very small value of p.

while(times<=p);{
while(ans*ans <=n){
ans = ans + inc;
}
ans = ans - inc;
inc = inc / 10;
times = times + 1;
}

This portion of your code is causing TLE.
Now, it’s your task to figure out your mistake.
It could be a syntax or a logic that you have implemented wrong.

Hint: The outer while loop is executing infinite no. of times.

Hope, this would help.
Give a like, if you are satisfied.

You have not answered to this thread for 5 days.
Please, mark this doubt as resolved if I have solved your doubt.
Else, ask your queries.