This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Assignment 6 1. Write a program to compute the roots of a quadratic equation ax 2 + bx + c = 0, where a, b, and c are real numbers. Structure your program as described below. A. The input file is named input_equations.txt which contains the three coefficients of an equation in each line as below: 1.0 -3.0 2.0 1 0 -4.84 1 0 1 You may create more inputs if you need. Open pico input_equations.txt 1.0 -3.0 2.0 1 4.84 1 1 B. Write a function compute_roots that has five parameters: a : Coefficient of x2 b : Coefficient of x c : constant term *root1 : pointer to a double type variable *root2 : pointer to a double type variable The function updates the memory locations pointed to by root1 and root2 with the two roots of the quadratic equation, if they have real-valued roots. If the roots are complex, then the memory locations are left unchanged. The function returns a value 1 if the roots are real-valued, otherwise returns 0....
View Full Document
This homework help was uploaded on 04/03/2008 for the course ECE 175 taught by Professor Grubbs during the Spring '08 term at University of Arizona- Tucson.
- Spring '08
- Computer Programming