Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++: //Write a program that does the following: Ask user to input three Real numbers a, b and c. They represent the parameters of

Using C++:

//Write a program that does the following:

Ask user to input three Real numbers a, b and c. They represent the parameters of a quadratic equation ^2 + + = 0

Classify to one of the following:

    • - Infinite number of solutions (for example, 0^2 + 0 + 0 = 0 has infinite number of solutions)

    • - No solution (for example, 0^2 + 0 + 4 = 0 has no solution)

    • - No real solution (for example, ^2 + 4 = 0 has no real solutions)

    • - One real solution

    • - Two real solutions

  • In cases there are 1 or 2 real solutions, also print the solutions.

    Notes:

1. If = 0 and there are real solutions to the equation, you can get these solutions using the following formula: x1,2 = (-b+/- sqrt(b^2-4ac)/2a The number of solutions depends on whether (b^2 -4ac) is positive, zero, or negative.

2. In order to calculate the square root of a number (of type double), you should call the sqrt function, located in the cmath library.

Follow the syntax as demonstrated in the code below:

 #include  #include  using namespace std; 

int main() { double x = 2.0;

 double sqrtResult; sqrtResult = sqrt(x); 
 cout 

} Note that you first need to include the cmath library, and then you can call the sqrt function, passing the argument that you want to calculate the square root of, enclosed in parentheses.

Your program should interact with the user exactly as it shows in the following example: Please enter value of a: 1 Please enter value of b: 4 Please enter value of c: 4

This equation has a single real solution x=-2.0//

The same question was answered here but the person who answered did not use the syntax the question mentioned and the answer was difficult to understand.

image text in transcribed

Question 3: Write a program that does the following: Ask user to input three Real numbers a, b and c. They represent the parameters of a quadratic equation ax2 + bx + c = 0 Classify to one of the following: 'Infinite number of solutions' (for example, 0x2 + 0x + 0 = 0 has infinite number of solutions) - "No solution' (for example, 0x2 + 0x + 4 = 0 has no solution) 'No real solution' (for example, x2 + 4 = 0 has no real solutions) - 'One real solution' - "Two real solutions' In cases there are 1 or 2 real solutions, also print the solutions. Notes: 1. If a 70 and there are real solutions to the equation, you can get these solutions using the following formula: X, X12 = - b vb2 - 4ac 2a The number of solutions depends on whether (b2-4ac) is positive, zero, or negative. 2. In order to calculate the square root of a number (of type double), you should call the sqrt function, located in the cmath library. Follow the syntax as demonstrated in the code below: #include #include using namespace std; int main() { double x = 2.0; double sqrtResult; sqrtResult = sqrt(x); cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions

Question

How is product cost information used by managers? Discuss.

Answered: 1 week ago