summaryrefslogtreecommitdiff
path: root/sem_2/HLIN202/TP/TP2/ex11/exo11.cpp
blob: d4fd4b85273a2d738997f88728f5a92343864624 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream>

int main () {
  int n, a;
  float x,y;
  std::cout<<"Entrez a et n, ce programme  calcule la racine carre de a via l'algorithme de Heron D'Alexandrie, avec une precision n "<<std::endl;
  std::cin >> a >>n;
  x = a;
  do {
  y = x;
  x = y/2 + a/(2*y);
  std::cout<<x<<std::endl;
  } while ( x-y < 1/n);
  return 0;
}