Showing posts with label Quadratic Equation. Show all posts
Showing posts with label Quadratic Equation. Show all posts

Monday, June 10, 2013

C++ Program to Solve the Quadratic Equation

Welcome to GSinghCodes. This is the first post on this Blog, hopefully I will continue to add more as time progresses.

Today I will explain the C Plus Plus Program which Solves the Quadratic Equation. Before we get started we need to look at the Quadratic Equations. "Standard Form" of a Quadratic Equation is ax2 + bx + c = 0, where a b and c are known, a cannot be zero and x is the unknown variable we have to find. To solve the equation we can use the quadratic formula:
Their are three types of answers you can get with the quadratic formula, Two real solutions (If the discriminant (the part inside the square root) is greater than zero) , No Real Solution (If the discriminant is strictly less than zero and One real solution(If the discriminant is equal to zero). To See Examples Click Here.

Examples To Test
 0x^2 + 0x + 0 = 0 Answer = "All Solutions"
 0x^2 + 0x + 1 = 0 Answer = "No Solutions"
 0x^2 + 2x + 1 = 0 Answer = -1/2
 1x^2 + 2x + 1 = 0 Answer = "Duplicate Solution" = -1
 1x^2 + 4x + 1 = 0 Answer = "two solutions" = d = 3.464 1st root = -0.267 | 2nd root = -3.73

C Plus Plus Program to Solve the Quadratic Equation