Computer Science, asked by Kumarcbharath145, 4 months ago

c program to find roots of quadratic equation by using if else statement​

Answers

Answered by bhaleraosnehal2419
4

Answer:

#include <stdio.h>

#include <math.h>

int main()

{

 int a, b, c, d;

 double root1, root2;

 printf("Enter a, b and c where a*x*x + b*x + c = 0\n");

 scanf("%d%d%d", &a, &b, &c);

 d = b*b - 4*a*c;

 if (d < 0) { // complex roots, i is for iota (√-1, square root of -1)

   printf("First root = %.2lf + i%.2lf\n", -b/(double)(2*a), sqrt(-d)/(2*a));

   printf("Second root = %.2lf - i%.2lf\n", -b/(double)(2*a), sqrt(-d)/(2*a));

 }

 else { // real roots

   root1 = (-b + sqrt(d))/(2*a);

   root2 = (-b - sqrt(d))/(2*a);

   printf("First root = %.2lf\n", root1);

   printf("Second root = %.2lf\n", root2);

 }

 return 0;

}

Answered by sameeksha712rawat
0

Answer:

A programme to find a quadratic equation's roots The sqrt() library function is employed in this programme to determine a number's square root.

Explanation:

What is quadratic equation's roots?

  • The polynomial equations of degree two in one variable of type f(x) = ax2 + bx + c = 0 and with a, b, c, and R R and a 0 are known as quadratic equations. It is a quadratic equation in its general form, where "a" stands for the leading coefficient and "c" for the absolute term of f. (x). The roots of the quadratic equation are the values of x that satisfy the equation (, ).
  • It is a given that the quadratic equation has two roots. Roots can have either a real or made-up nature. When a quadratic polynomial is equal to zero, a quadratic equation results. The roots of the quadratic equation are the values of x that satisfy the equation.From general: ax2 + bx + c = 0.

To learn more about coefficient refer to:

https://brainly.in/question/49464968

https://brainly.in/question/842391

#SPJ2

Similar questions