Posts

Showing posts from February, 2021

find the roots of the equation ax^2 + bx + c using C language

#include <stdio.h> #include <math.h>     /* find the roots of the equation ax^2 + bx + c */   int   main (){    float  a,b,c,discriminant,root1,root2;          printf ( "Enter a, b and c of quadratic equation: " );    scanf ( "%f%f%f" ,&a,&b,&c);       discriminant = b * b -  4  * a * c;       if (discriminant <  0 )   {      printf ( "Roots are complex number. \n " );        printf ( "Roots of quadratic equation are: " );      printf ( "%.f%+.fi" ,-b/( 2 *a), sqrt (-discriminant)/( 2 *a));      printf ( ", %.f%+.fi" ,-b/( 2 *a),- sqrt (-discrimina...