Posts

Showing posts with the label Roots

Finding Roots of Quadratic Equation using C++

Image
This is a simple programming tutorial for finding roots ( x 1 and x 2 ) of the quadratic equation ( ax 2  +  bx  + c = 0) using C++. In this tutorial, I have used Dev C++ v5.11 software for compiling the C++ program. About Quadratic Equation In algebra, a quadratic equation ( quadratus → square → 2 ) is an equation having the form ax 2  +  bx  + c = 0, where x represents an unknown number ( aka variable), and a , b , and c represent known numbers ( aka constants). The formula for solving roots of the quadratic equation is \[x=\frac{-b\pm \sqrt{{{b}^{2}}-4ac}}{2a}\]. The term b 2 - 4 ac is known as the determinant ( D ) of the quadratic equation, which determines the type of the root. Roots of the quadratic equation are broadly categorized into three categories as shown below: Discriminant Formula Roots b 2 - 4 ac = D > 0 \[{{x}_{1}}=\frac{-b+\sqrt{{{b}^{...