Return to site

C Program To Find Quadratic Equation

broken image


  1. C Program To Find Roots Of Quadratic Equation Using Pointers
  2. C Program To Find Roots Of Quadratic Equation With Flow Chart
  3. C Program To Find Roots Of Quadratic Equation Using Functions
  • What is Quadratic Equation? A Quadratic Equation is any time of the equation that can be rearranged in the standard form as ax^2+bx+c=0. Where, x is the unknown variable and the a,b,c are the known numbers where a!=0. If a=0 then the equation is said to be linear and not a quadratic equation as there is no ax^2.
  • Logic to find roots of quadratic equation using switch.case. Step by step descriptive logic to find roots of quadratic equation using switch case. 1.Input coefficients of quadratic equation. Store it in some variable say a, b and c. 2.Find discriminant of given equation using formula i.e. Discriminant = (b. b) - (4. a. c).

C program to find roots of a quadratic equation: It calculates the roots of a quadratic equation. Coefficients are assumed to be integers, but roots may or may not be real. For a quadratic equation ax 2 + bx + c = 0 (a≠0), discriminant (b.b-4.a.c) decides the nature of roots. C program to find the roots of a quadratic equation using switch case: The below program ask the user to enter the value of a,b and c. After getting the value from the user it will calculate on the basis of ‘Discriminant' value using switch case.

In this blog post, we learn how to write a C program to find the roots of a quadratic equation?. We will write the C program to find the roots of a quadratic equation using the if-else condition. Write C program to find roots of quadratic equation using switch statements. How to find all roots of a quadratic equation using if else in C programming. Logic to find roots of quadratic equation in C programming.

Let see an example,

Quadratic equation:

In algebra, a quadratic equation is an equation that can be rearranged in standard form as,

Below is a direct formula for finding the roots of the quadratic equation.

There are the following important cases of this formula.

Case 1: (Discriminant < 0)

Case 2: (Discriminant 0)

Case 3 (Discriminant > 0):

C Program to Find the Roots of a Quadratic Equation using if-else:

The below program ask the user to enter the value of a,b and c. After getting the value from the user it will calculate on the basis of ‘Discriminant' value.

Output:

Enter value of a of quadratic equation (aX^2 + bX + c): 2
Enter value of b of quadratic equation (aX^2 + bX + c): 7
Enter values of c of quadratic equation (aX^2 + bX + c): 2
Two distinct and real roots exist: -0.31 and -3.19

C++ quadratic equation solver

C program to find the roots of a quadratic equation using a function:

Output:

Enter value of ‘a' of quadratic equation (aX^2 + bX + c): 5
Enter value of ‘b' of quadratic equation (aX^2 + bX + c): 2
Enter values of ‘c' of quadratic equation (aX^2 + bX + c): 2
Two distinct complex roots exists: -0.20 + i0.60 and -0.20 – i0.60

Shape files in canvas draw for mac 5. A quadratic equation is of the form ax2 + bx + c = 0 where a ≠ 0. A quadratic equation can be solved by using the quadratic formula. You can also use Excel's Goal Seek feature to solve a quadratic equation.

1. For example, we have the formula y = 3x2 - 12x + 9.5. It's easy to calculate y for any given x. For x = 1, y = 0.5

2. For x = 2, y = -2.5

3. But what if we want to know x for any given y? For example, y = 24.5. We need to solve 3x2 - 12x + 9.5 = 24.5. We can solve the quadratic equation 3x2 - 12x + 9.5 - 24.5 = 0 by using the quadratic formula.

3x2 - 12x -15 = 0
a = 3, b = -12, c = -15
D = b2- 4ac = (-12)2 - 4 * 3 * -15 = 144 + 180 = 324

C Program To Find Roots Of Quadratic Equation Using Pointers


x = -b + √Dorx = -b - √D
2a2a
x = 12 + √324orx = 12 - √324
66
x = 12 + 18orx = 12 - 18
66
x = 5orx = -1

4. You can use Excel's Goal Seek feature to obtain the exact same result. On the Data tab, in the Forecast group, click What-If Analysis.

5. Click Goal Seek.

The Goal Seek dialog box appears.

6. Select cell B2.

7. Click in the 'To value' box and type 24.5

Best 3d cad for mac. 8. Click in the 'By changing cell' box and select cell A2.

9. Click OK.

C Program To Find Roots Of Quadratic Equation With Flow Chart

Result.

C Program To Find Roots Of Quadratic Equation Using Functions

Note: Excel returns the solution x = 5. Excel finds the other solution if you start with an x-value closer to x = -1. For example, enter the value 0 into cell A2 and repeat steps 5 to 9. To find the roots, set y = 0 and solve the quadratic equation 3x2 - 12x + 9.5 = 0. In this case, set 'To value' to 0.





broken image