Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program write a function in ANSI C that compute both roots of a quadratic equation int solve(double a, double b, double c,

Write a C program

write a function in ANSI C that compute both roots of a quadratic equation

int solve(double a, double b, double c, double *root1, double *root2) that solve ax^2+bx+c=0, using solution (-b+ - sqrt(b^2-4ac)/2a

function solve should return either 2(two root were found), 1(one root was found) , 0(no roots were found). need not check for overflow. If one one root is found, it should be returned in root1. you may assume that a is not 0.

write a testing function tester(double a, double b, double c, char *msg)

that calls your solve() function and prints out the result along with the ms passed as arguent. tester should only printout the correct number of roots.

write a main function that tests your code above. main function should at least call

tester(1.0,0.0,4.0,"no solution");

tester(1.0,0.0,-4.0,"two solution");

tester(1.0,0.0,0.0,"one solution");

note: the sqrt() function is defned in the math library (include file and library -lm

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

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

How do they research and outline writing projects?

Answered: 1 week ago