need help C++ program




1) Produce a table for ax2 + bx + c = 0

where a= -1, 1 and 2; b = -2 thru 3 ; and c= -4 thru +2



Heading line a b c Root1 Root2


when b2 -4ac < 0 indicate no real roots


###EXTRA CREDIT show imaginary roots w/ i

Break it down into pieces. As I start, try writing a function that takes the values of a, b, and c, and prints one line of the output. Have your main program test it out:

1
2
3
4
5
6
7
8
9
10
11
void solveQuadratic(double a, double b, double c)
{
    // compute the roots (if they exist) then print one line of the out
    // i.e., print a b c root1 root2
}

int main(int argc, char **argv)
{
    solveQuadratic(1,2,3);
    solveQuadratic(-1, -2, 3);
}


Verify by hand that you're getting the right answers. Next change main() to produce the table required, complete with headings.
Last edited on
Topic archived. No new replies allowed.