Create a structure named quad that has three data numbers of the type double for the a, b, and c coefficients of a quadratic polynomial: f(x) = ax^2 + bx + c
Write a main() function that will declare and initialize a quad structure and display the values of the coefficient. Now write and test the following functions:
1) Function readValue() that takes a single reference argument to a quad structure and a void return type. It should ask the user to enter values for the a, b, and c.
2) Function showValue() that takes a single reference argument to a quad structure and a void return type. It should display the quadratic on the terminal in this form: -2x^2 - 4x +35 3) Function addQuad() that takes references to two quad structures as parameters and returns a quad structure that is the sum of the two input quad structures. For quadratic functions f(x) = ax^2 + bx + c and g(x) = dx^2 + ex + f the sum is given by f(x) + g(x) = (a+d)x^2 + (b+e)x + c + f
Demonstrate these functions in a main() program by doing the following: 1) Enter the following 2 quadratic functions using the readValue() function: f(x) = 5x^2 - 2x + 3 and g(x) = 4x^2 + 3x +7 2) Determine the sum of f(x) + g(x) using teh addQuad() function.
3) Display the resulting polynomial using the showValue() function.
I started it but can you explain how i would do part 2)? What would the addQuad() function look like and how do i call these functions in the main program?
A quick once-over and it looks fine to me. The parameters to showValue() and to addQuad() should be const references though. Is it working the way you intend it to?
I don't have a compiler or program to run it on my laptop so I have no way of knowing until I can manage to go to the computer labs but it's due in two days so I wanted someone's opinion to see if I was on track.