Back
Close

3 - Les alternatives et les structures

Pedro77
13.2K views

Exercice 5

Calculer les racines d’une équation du second degré.

$$ax^2 + bx + c = 0 $$
$$\Delta = b^2 - 4ac $$
$$x_1,x_2 = \frac{-b \pm \sqrt{\Delta}}{2a} $$

Exemples (valeurs de tests) :

  • 1 x² + 2x -3 => delta > 0 => x1 = 1 et x2 = -3
  • 1 x² + 2x +1 => delta = 0 => x1 = -1 et x2 = -1 (normal, une seule solution si delta nul)
  • 1 x² + 1x +1 => delta < 0 => Pas de solutions dans R
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io