Computer Science, asked by aditioraon637, 2 months ago

Write a C program to find the Nature (Real/Imaginary) of the roots of the quadratic equation and print them.​

Answers

Answered by anu18256
1

Explanation:Steps to find the square roots of the quadratic equation:

1) Initialize all the variables used in the quadratic equation.

2) Take inputs of all coefficient variables x, y and z from the user.

3) And then, find the discriminant of the quadratic equation using the formula:

3) And then, find the discriminant of the quadratic equation using the formula:Discriminant = (y * y) - (4 * x *z).4) Calculate the roots based on the nature of the discriminant of the quadratic equation.If discriminant > 0, thenIf discriminant > 0, thenRoot1 = (-y + sqrt(det)) / (2 * x)If discriminant > 0, thenRoot1 = (-y + sqrt(det)) / (2 * x)Root2 = (-y + sqrt(det)) / (2 * x)If discriminant > 0, thenRoot1 = (-y + sqrt(det)) / (2 * x)Root2 = (-y + sqrt(det)) / (2 * x)5) Print the roots are real and distinct.Else if (discriminant = 0) then,Else if (discriminant = 0) then,Root1 = Root2 = -y / (2 * x).Else if (discriminant = 0) then,Root1 = Root2 = -y / (2 * x).

6) Print both roots are real and equal.Else (discriminant < 0), the roots are distinct complex where,Else (discriminant < 0), the roots are distinct complex where,Real part of the root is: Root1 = Root2 = -y / (2 * x) or real = -y / (2 * x).Else (discriminant < 0), the roots are distinct complex where,Real part of the root is: Root1 = Root2 = -y / (2 * x) or real = -y / (2 * x).

7) Imaginary part of the root is: sqrt( -discriminant) / (2 * x).Print both roots are imaginary, where first root is (r + i) img and second root is (r - i) img.

8) Exit or terminate the program

all the best

Similar questions