Você está na página 1de 1

FE1008 Computing

Take Home Exercise


To be submitted in the Group AS3 submission folder before the end of class next week

Write a program to solve the quadratic equation ax2 + bx + c = 0 fully, delivering explicitly one of the
four possible solutions:
1. One single real root
2. Repeated real root
3. Two distinct real roots
4. Two complex roots

Your program should read in the coefficients a, b and c, and then proceed to find the solutions.
Some possible dialogues (underlined texts are user inputs):

Enter coefficients a, b and c: 0.0 2.0 5.2


One real root: x = -2.60

Enter coefficients a, b and c: 1.0 -4.0 4.0


Repeated real root: x = 2.00

Enter coefficients a, b and c: 0.0 1.0 -2.0


Two real roots: x = -2.00, x = 1.00

Enter coefficients a, b and c: 2.0 2.0 5.0


Two complex roots: x = -0.50 + i1.50, x = -0.50 – i1.50

You should test your program with different inputs, not just those shown in the examples above.

For submission, your file name should be your name. Submit your C program only. The first line of
your program should be a comment line containing your name.

Você também pode gostar