I am trying to write a code that solves quadratic equations. After entering the 3 constants of the equations, nothing happens. The programs ends even though there are conditions.
This is the code. Thank you for the help.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
printf("Se va a trabajar con la ecuacion de la forma ax^2+bx+c\n\n" );
float a,b,c,x_1,x_2,x_0;
printf("Ingrese el valor de la constante a: ");
scanf("%f", &a);
printf("Ingrese el valor de la constante b: ");
scanf("%f", &b);
printf("Ingrese el valor de la constante c: ");
scanf("%f", &c);
double dis = b*b-4*a*c;
double sqr = sqrt(dis);
if(sqr<0){
printf("No tiene solucion en los numeros reales");
}
if(sqr==0){
x_0= -b/(2*a);
printf("La solucion es %f", x_0);
}
if(sqr>0){
x_1= (-b + sqr)/(2*a);
x_2= (-b - sqr)/(2*a);
printf("Las soluciones son %f y %f", x_1, x_2);
}
}