#include<iostream.h>
#include<iomanip.h>
#include<math.h>
#include<stdlib.h>
int trt;
int pair(double y,int k){
y=y*pow(10,(k-1)*2);
int n=y;
y=y-n;
y=y*100;
n=y;
return n;
}
int scal2(int s,int f){
f=f*20;
for(int j=9;j>=0;j--)
{
if((j*(j+f))<s){>
return(s-(j*(j+f)));
break;
}
}
}
int sqcalc(int g,int h){
h=h*20;
for(int j=9;j>=0;j--)
{
if((j*(j+h))<g){>
return j;
break;
}
}
}
double sqroot(double x,double res){
double ans;
int r,a;
r=sqrt(x);
ans=r;
r=x-ans;
for(int i=1;i<=res;i++){
r=(r*100)+pair(x,i);
double d=scal2(r,ans);
ans=(ans*10)+sqcalc(r,ans);
r=d;
}
ans=ans/(pow(10,res));
return ans;
}
int main(){
cout << setprecision(10)<< sqroot(2,5);
return(0);
}</stdlib.h></math.h></iomanip.h></iostream.h>
here sqroot(a,b) returns value of square root of a upto b decimal places.there is an another problem.for root 2 it works upto 5 places,but after that it goes to 60!what do you think could be the cause?(please help me i am a novice programmer,maybe even worse!)