Write a program in C to compute the roots of a quadratic equation (ax² + bx + c = 0). The roots of the equation can be calculated using the following formulae: x1 = (-b + sqrt(b² - 4ac))/2a x2 = (-b – sqrt(b? - 4ac ))/2a Note: If b? – 4ac is negative, the roots are complex.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Write a program in C to compute the roots of a quadratic equation (ax² + bx + c = 0).
The roots of the equation can be calculated using the following formulae:
x1 = (-b + sqrt(b? – 4ac))/2a
x2 = (-b – sqrt(b? - 4ac ))/2a
Note: If b? – 4ac is negative, the roots are complex.
Write your program in the space provided. Using text editor, type and save your program.
Test your program to solve the following equations:
(a) x + 2x – 15 = 0
(b) 4x +x+3 =0
(c) x? – 8x + 16 = 0
(d) 7x – 5 = 0
Use CodeBlocks. Take a picture
of the code and results.
A flow chart to solve the problem is shown below.
Start
Input a,b,c
True
a -- 0
False
X = -/b
disc = b2 - 4ac
Print Not a Quadratic
Equation
Print x
False
True
disc --0
False
X = -b/2a
X = -b/2a
disc >0
True
ximg, - sort(disc)/2a
ximag, - sgrt(disc)/2a
xr = -b/(2*a)
X - (-b + sgrt(disc)/2a
X, - (-b - sart(disc) y2a
Print x, X2
Print x, X
Print xr, ximg, ximg
Stop
Transcribed Image Text:Write a program in C to compute the roots of a quadratic equation (ax² + bx + c = 0). The roots of the equation can be calculated using the following formulae: x1 = (-b + sqrt(b? – 4ac))/2a x2 = (-b – sqrt(b? - 4ac ))/2a Note: If b? – 4ac is negative, the roots are complex. Write your program in the space provided. Using text editor, type and save your program. Test your program to solve the following equations: (a) x + 2x – 15 = 0 (b) 4x +x+3 =0 (c) x? – 8x + 16 = 0 (d) 7x – 5 = 0 Use CodeBlocks. Take a picture of the code and results. A flow chart to solve the problem is shown below. Start Input a,b,c True a -- 0 False X = -/b disc = b2 - 4ac Print Not a Quadratic Equation Print x False True disc --0 False X = -b/2a X = -b/2a disc >0 True ximg, - sort(disc)/2a ximag, - sgrt(disc)/2a xr = -b/(2*a) X - (-b + sgrt(disc)/2a X, - (-b - sart(disc) y2a Print x, X2 Print x, X Print xr, ximg, ximg Stop
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY