Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions