- Find Quadratic Equation From Table
- How To Do Quadratic Equations
- C Program To Find Roots Of Quadratic Equation In Ubuntu
In this tutorial, we will learn to find the roots or solutions of a quadratic equation in C++. In mathematics, these equations are used in fields such as simplification of expressions, equations of a circle and other conic sections, etc. Here, we will learn a method to find the roots of these equations, and a C++ program that calculates the roots of a given quadratic equation.
![C program to find roots of quadratic equation in ubuntu C program to find roots of quadratic equation in ubuntu](https://i.ytimg.com/vi/bNmAAKS-b-k/hqdefault.jpg)
Below is direct formula for finding roots of quadratic equation. There are following important cases. If b.b c, then roots are complex (not real).For example roots of x 2 + x + 1, roots are -0.5 + i1.73205 and -0.5 - i1.73205 If b.b 4.a.c, then roots are real and both roots are same. I am using Dev C compiler.i have the C code to solve a quadratic equation.the.exe file runs very well and provide the required solutions.my problem is that i want the program to function in a gui environment still using C language and the same Dev C compiler.possible?please help.! 4/5/16, 9:41 PM.
Quadratic equation
The general quadratic equation is as follows –
Ax^2 + Bx + C = 0
where,
- A, B, and C are known values.
A is the coefficient of the term containing x^2. Also, A cannot be 0.
B is the coefficient of the term containing x.
C is a constant value. - x is an unknown value or variable
The name ‘quadratic’ means square because the equations contain the square of the unknown variable. The quadratic equations are of degree 2.
For example –
5x^2 + 4x + 1 = 0
x^2 + 2x + 1 = 0
5x^2 + 4x + 1 = 0
x^2 + 2x + 1 = 0
Finding roots of a quadratic equation
Every quadratic equation has exactly two roots. The roots can be equal or distinct, and real or complex. So, to find the nature of roots, calculate the discriminant using the following formula –
Zaxwerks pro animator torrent. Discriminant, D = B^2 – 4AC
- Case 1 – D < 0
If D is less than 0, then the roots and distinct and complex. - Case 2 – D = 0
If D is equal to 0, then the roots are equal and real. - Case 3 – D > 0
If D is greater than 0, then both the roots are real and distinct.
To find both the roots, we use the formula given below –
Root1 = ( -B + square_root(D) ) / 2A
Root2 = ( -B – square_root(D) ) / 2A
Root2 = ( -B – square_root(D) ) / 2A
Program to find roots of a quadratic equation in C++
Now, we will see a program that calculates the roots of a quadratic equation using C++. The program takes the coefficients i.e. A, B, and C from the user and then finds the roots. The C++ program to find roots of the equation is –
In this program, we find the square root using the in-built sqrt() function of the ‘cmath’ library. The program displays both the roots of the given quadratic equation.
C++ program output
The output of the above program is –
Find Quadratic Equation From Table
The user has entered the value of A, B, and C as 1, 2, and -8 respectively. The roots of the equations always satisfy the equations.
For example –
For example –
So, both the roots satisfy the equation.
Thank you for reading this tutorial. I hope it helps you a lot.
C Program To Find Roots of Quadratic Equation
![C program to find roots of quadratic equation using functions C program to find roots of quadratic equation using functions](https://i.ytimg.com/vi/NmRPJUiizpg/maxresdefault.jpg)
Learn How To Find Roots of Quadratic Equation in C Programming Language using If – Else Block Structure. This Code To Calculate Quadratic Roots of an Equation is without Functions and also has an Output Screen displayed at the bottom of this page.
What is a Quadratic Equation?
The Standard Form of a Quadratic Equation is ax2 + bx + c = 0, where x is a variable entity and a, b, c are constant values which cannot be changed.
Formula For Quadratic Equation
z = −b ± √(b2 − 4ac) / 2a
How To Do Quadratic Equations
Conditions For Discriminants
- If b2 − 4ac is Negative, Two Complex Solutions are possible
- If b2 − 4ac is Positive, Two Real Solutions are possible
- If b2 − 4ac = 0, One Real Solution is possible
Also Read: C Program To Remove Vowels From A String
C Program To Find Roots of Quadratic Equation
2 4 6 8 10 12 14 16 18 20 22 24 26 28 | #include<math.h> intmain() floatroot1,root2,discriminant; printf('nEnter The Valuesn'); scanf('%f',&a); scanf('%f',&b); scanf('%f',&c); if(discriminant<0) printf('nRoots Are Imaginaryn'); else root1=(-b+sqrt(discriminant))/(2*a); printf('nRoot 1 = %fn',root1); } return0; |
Note: If you Compile this Code in Linux, you will get a Linker Error. It is because the implementation of sqrt() method is missing and it is defined in libm library in GNU GCC Compiler. Therefore, you have to explicitly apply it while compilation.
Command: gcc test.c -lm
Also Read: Find Sum of Lower Triangular Elements of Matrix C Program
Output
C Program To Find Roots Of Quadratic Equation In Ubuntu
If you have any compilation errors or doubts in this Program to Find Roots of Quadratic Equation in C Programming Language, let us know about in the Comment Section below.
Jun 09, 2020 The M-Tron Pro virtual instrument is a remarkable emulation of the classic Mellotron — the unique tape playback keyboard made famous by such luminaries as The Beatles, Yes, Led Zeppelin and The Moody Blues. M-Tron Pro Library v3.0.0: 8.53 Gb M-Tron Pro is the industry standard emulation of the classic Mellotron - the unique tape playback keyboard originally manufactured in the UK in the early 1960s and made famous by such luminaries as The Beatles, Yes, Led Zeppelin and The Moody Blues. M-Tron Pro is the industry standard emulation of the classic Mellotron - the unique tape playback keyboard originally manufactured in the UK in the early 1960s and made famous by such luminaries as The Beatles, Yes, Led Zeppelin and The Moody Blues. Torrent m tron pro.