I made the corrections but 1.why you use float inside if statement and 2. its not showing output for 20

#include
using namespace std;
int main()
{
int n;
float k=1.0,sum=0.0;
cin>>n;
label:
for(float i=0;;i=i+k)
{
if(((sum+i)*(sum+i))>n)
{
i=i-k;
sum=sum+i;
k=k/10;
if(k==((float)0.0001))
{
goto end;
}
else goto label;
}
}
end:
cout<<"\n"<<sum;
return 0;
}

Hey @prerak_semwal
some compilers will take 0.000001 as 0 so to avoid that we typecast it to float
u can alternatively use 0.000001f
Reply here if u dont understand
Please Dont open mupltiple threads for the same doubt

Checking it for 20

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.