Email
 Submitted on: 1/2/2015 5:24:00 AM By: Guy Fischman (from psc cd) Level: Beginner User Rating: By 2 Users Compatibility: C, C++ (general) Views: 950

This code applies the quadratic formula to an equation and derives the variable value given the three coefficients.

### INCLUDE files:

Can't Copy and Paste this?
 ```//************************************** //INCLUDE files for :Calculates Quadratic Formula //************************************** iostream.h math.h```
code:
Can't Copy and Paste this?
 ``` //************************************** // Name: Calculates Quadratic Formula // Description:This code applies the quadratic formula to an equation and derives the variable value given the three coefficients. // By: Guy Fischman (from psc cd) // // Inputs:Three coefficients of a quadratic equation. // // Returns:Value of unknown variable. //************************************** #include #include void main() { double A; double B; double C; double disc; cout << "Enter A: "; cin >> A; cout << "Enter B: "; cin >> B; cout << "Enter C: "; cin >> C; disc = B*B - 4*A*C; if (disc < 0){ cout << "Imaginary results: " << endl; cout << "(" << B * (-1) << " + " << sqrt(disc * (-1)) << "i) / " << 2*A << endl; cout << "(" << B * (-1) << " - " << sqrt(disc * (-1)) << "i) / " << 2*A << endl; } else if (disc == 0){ cout << "Single result: " << (-B)/(2*A) << endl; } else{ cout << "Two results: " << endl; cout << (B * (-1) + sqrt(disc)) / (2*A) << endl; cout << (B * (-1) - sqrt(disc)) / (2*A) << endl; } }```

Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)