#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ float g,r,c=0,n,pg; //g guess pg previous guess
cout<<"enter the number to find squareroot ";
cin>>n;
g=n/2; pg=n;
while(g!=pg)
{r=n/g;
pg=g;
g=(g+r)/2;
}
cout<<"square root \t"<<g<<endl;
getch();
No comments:
Post a Comment