# assignment2 - Program statement This program will solution...

• Notes
• 1

This preview shows page 1. Sign up to view the full content.

Sheet1 Page 1 /* Program statement This program will solution to a quadratic formula using the user inputted coefficeints A, B and C. #include <iostream> #include <iomanip> #include <math.h> using namespace std int main() { float A, B, C, Discrim cout << scientific << setprecision(4) << endl << "This program will provide solutions for an equation of the form:" << "\n\n\t\tA*x^2 + B*x + C = 0\n\n" << "where A, B and C are integers, and A is not equal to zero.\n\n" << "Please enter the integer values for A, B and C separated by spaces: " cin >> A >> B >> C Discrim = B * B - 4 * A * C if (A == 0) cout << "\nNo solutions will be calculated for a leading coefficient of 0!"
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: << endl << endl else if (Discrim > 0) { cout << "\nThe two real solutions are:\t x = " << (-B + sqrt(B * B - 4 * A * C)) / (2 * A) << "\n and:\t x = " << (-B - sqrt(B * B - 4 * A * C)) / (2 * A) << endl << endl return 0 } else if (Discrim == 0) { cout << "\nThe one real solutions is:\t x = " << -B / (2 * A) << endl << endl return 0 } else if (Discrim < 0) { cout << "\nThe two imaginary solutions are:\t" << -B / (2 * A) << " + " << (sqrt(-(B * B - 4 * A * C))) / (2 * A) << " * i" << "\n and:\t" << -B / (2 * A) << " - " << (sqrt(-(B * B - 4 * A * C))) / (2 * A) << " * i" << endl << endl return 0 } }...
View Full Document

• Summer '07
• Ghyam

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern