C Program To Solve Second Order Quadratic Equation

C Program To Solve Second Order Quadratic Equation

#include<stdio.h>
#include<math.h>

int main()
{

   float a, b, c;
   float desc, root1, root2;

   printf("Enter the Values of a : \n");
   scanf("%f", &a);   //input from user
 
   printf("Enter the Values of b : \n");
   scanf("%f", &b);  //input from user
 
   printf("Enter the Values of c :\n");
   scanf("%f", &c);  //input from user

   desc = sqrt(b * b - 4 * a * c);

   root1 = (-b + desc) / (2.0 * a);
   root2 = (-b - desc) / (2.0 * a);

   printf("First Root : %f\n", root1);   //Print Output On screen
   printf("Second Root : %f\n", root2);  //Print Output On screen

}

Related Posts