Skip to content

Instantly share code, notes, and snippets.

@ChrisOrozco97
Created November 23, 2015 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisOrozco97/086a026b7957390f241a to your computer and use it in GitHub Desktop.
Save ChrisOrozco97/086a026b7957390f241a to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main()
{
int n, count(10);
double x, y, z;
cout<< "Escribe un número para calcular su raíz cuadrada"<<endl;
cin >> n;
cout << "Teclea un número para dividir"<<endl;
cin >> y;
z = n/y;
y = (y + z)/2;
while (count > 0)
{
z = n/y;
y = (y + z)/2;
if (y <= (y * 0.01) + y)
{
x = y;
}
else
z = n/y;
y = (y + z)/2;
count-=1;
}
cout << "La raíz cuadrada de "<< n << " es " << x;
cout << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment