Seeking a quadratic equation: ax2 + bx + c = 0 the roots. Input three real numbers a, b, c values, and a is not equal to zero.
#include <stdio.h> #include <math.h> int main () { the printf ( " Please enter the A, B, C \ n- " ); a float A, B, C, T, P, Q, X1, X2 ; scanf_s ( " % F% F% F " , & a, & B, & C); IF (a == 0 ) the printf ( " not a quadratic equation " ); the else { T = B * B - . 4 * a * C; IF (T>= 0 ) { / * realistic Root * / X1= (-B + sqrt (T)) / ( 2 * A); X2 = (-b - sqrt (T)) / ( 2 * A); the printf ( " There is a real roots \ n- " ); the printf ( " % F = X1 \ = NX2 F% \ n- " , X1, X2); } the else { P = (-b) / ( 2 * A); / * real part * / Q = sqrt (-t) / ( 2 A *); / * find the imaginary part * / the printf ( " there is virtual roots \ n- " ); the printf ( "%f+%f i\n", p, q); printf("%f-%f i\n", p, q); } } }