Finding roots of the quadratic equation in c language.

                     Roots of the quadratic equation

Hello, friends in this blog you will come across solution of the problem how to find roots of the quadratic equation in c language.Everyone knows that quadratic equation has degree two.
We can find the roots of the quadratic equation using  sridharacharya   formula.


                                                         

                         
https://programminghub1999.blogspot.com/2018/12/finding-roots-of-quadratic-equation-in.html



                        Following method has used in finding the roots of quadratic equation



  1. Take the coefficient of x,y,and constant term.
  2. Find the discriminant using formula.
  3. Then use the following concept in finding roots of quadratic equation.
                     


   If  discriminant=b*b-4*a*c  comes out to be less than zero than roots of the quadratic equation
   is imaginary.Otherwise we are able to find the roots of quadratic equation.


                         Programme to find roots of quadratic equation.

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
    clrscr();
    float a,b,c,discriminant,root1,root2;
    printf("Enter values of a,b and c \n \n");
    scanf("%f %f %f",&a,&b,&c);
    discriminant=b*b-4*a*c;
    if(discriminant<0)
       printf("\n Roots are imaginary \n");
   else
     {
         root1=(-b+sqrt(discriminant))/(2.0*a);
         root2=(-b-sqrt(discriminant))/(2.0*a);
         printf("Roots are %f  and %f\n",root1,root2);
     }
       getch();
}



         
 


Finding roots of the quadratic equation in c language. Finding roots of the quadratic equation in c language. Reviewed by Deepak kumar soni on December 24, 2018 Rating: 5

No comments:

Powered by Blogger.