Question: Program in C: A quadratic equation is an equation in the form The roots of a quadratic equation are values of x that cause the

Program in C:

A quadratic equation is an equation in the form

The roots of a quadratic equation are values of x that cause the equation to evaluate to 0 and can be solved for using the quadratic equation:

Depending on the values of a, b, and c there may be 0, 1, or 2 real solutions. Write a program called quad.c that asks the user for a, b, and c and then displays the real roots of x if there are any.

Assumptions

  • Input will always be valid
  • a will never be 0

Tips

  • When there are 2 solutions the + solution is printed first
  • You may need to compile with the -lm flag on the command line to use the functions inside of math.h

Requirements

  • Program must compile with both -Wall and -Werror options enabled
  • Submit only the files requested
  • Use doubles to store real numbers
  • Print all doubles to 2 decimal points unless stated otherwise

Restrictions

  • No global variables may be used
  • Your main function may only declare variables and call other functions

Examples

In the examples below user input has been underlined. You don't have to do any underlining in your program. It is just there to help you differentiate between what is input and what is output.

Example 1

Given a quadratic equation of the form a*x^2 + b * x + c Please enter a: 1 Please enter b: 2 Please enter c: 1 There is one real solution: -1.00

Example 2

Given a quadratic equation of the form a*x^2 + b * x + c Please enter a: 4 Please enter b: 3 Please enter c: 7 There are no real solutions

Example 3

Given a quadratic equation of the form a*x^2 + b * x + c Please enter a: 3 Please enter b: 11 Please enter c: 8 There are 2 real solutions Solution 1: -1.00 Solution 2: -2.67

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!