Question
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started