This program uses an ancient method to find the square root.
But the problem is that it only works with certain numbers not all the numbers I input.
I would like to know if I am doing anything wrong.
I would appreciate any help I could get with this.
#include<iostream>
#include<iomanip>
using std::setprecision;
using std::cout;
using std::cin;
void main()
{
double number;
double divisor = 1.0000;
double quotient;
int tolerance;
char result;
do{
cout<<"Enter the number to find the square root: ";
cin>>number;
cout<<"\nEnter a number (1-9) to get a specific tolerance: ";
cin>>tolerance;
while(divisor!=quotient)
{
quotient = number/divisor; // Using the method of averages
divisor = (divisor + quotient) / 2;
if(quotient == divisor)
{
cout<<"\nThe Square Root is: "<<setprecision(tolerance)<<divisor<<'\n';
}//close if
}// close while
cout<< "\nDo you want to try again ? (y/n) ";
cin >> result;
cout<<'\n';
}while(result == 'y');
}//close main