Write a function @numsols2deg(a, b, c)@ that receives as argument the three coefficients of the 2nd degree equation and returns how many real solutions it has: 0, 1, or 2.
The solutions of that equation are given by the expression (best seen in the pdf version of the statement).
The expression is called its discriminant: if it is negative, then the square root cannot provide real values, and there are no real solutions; if the discriminant is 0, then the square root is also 0 and the two options coincide, so that there is a single real solution; if the discriminant is positive, then we obtain two real solutions.
Author: ProAl
Generation: 2026-01-25T17:14:17.832Z
© Jutge.org, 2006–2026.
https://jutge.org