Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am in an intro to C++ class. Use the iostream library Create a structure named

ID: 3653740 • Letter: I

Question

I am in an intro to C++ class. Use the iostream library 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.

Explanation / Answer

#include using namespace std; //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 struct quad{ double a,b,c; }; void readValue(quad&); void showValue(quad&); quad addQuad(quad&,quad&); //Write a main() function that will declare and initialize a quad structure // and display the values of the coefficient. int main(){ quad One; // declare One.a=1; //initialize a One.b=2; //initialize b One.c=3; //initialize c cout