# Program in c to Find the roots of a Quardratic equation

## Write a Program in c to Find the roots of a Quardratic equation

\* C Program to to Find the roots of a Quardratic equation *\

# include < stdio.h >
int   main( )
{

float   a, b, c, d, root1, root2  ;
printf(" A quadratic equation are a x*x + b x + c = 0: \n") ;
printf("\n Enter the value of a :") ;
scanf("%d ", & a) ;
printf("\n Enter the value of b :") ;
scanf("%d ", & b) ;
printf("\n Enter the value of c :") ;
scanf("%d ", & c) ;

d = b * b - 4 * a * c ;
if ( d < 0 )
{

printf("\n Roots of quardratic equation are complex number. \n") ;
printf("\n Roots of quadratic equation are: \n ") ;
printf(" %.3f%+.3fi ", -b/(2*a), sqrt(-d)/(2*a)) ;
printf(", %.3f%+.3fi ", -b/(2*a), -sqrt(-d)/(2*a)) ;

}
else
{

if ( d == 0 )
{

printf("\n Both roots are equal.\n") ;
root1 = -b /(2* a) ;
printf("\nRoot of quadratic equation is: \n%.3f ", root1) ;

}
else
{

printf("\n Roots are real numbers. \n") ;
root1 = ( -b + sqrt(d)) / (2* a) ;
root2 = ( -b - sqrt(d)) / (2* a) ;
printf("\n Roots of quadratic equation are: \n %.3f , %.3f", root1, root2) ;

}

}
return ( 0 ) ;

}

## Output of Program: 