Create a structure named quad that has three data members of type double for the
ID: 3654341 • Letter: C
Question
Create a structure named quad that has three data members of 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 coefficients. Now write and test the folllowing 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 data members. (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 paramenters 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 + fExplanation / Answer
#include using namespace std; struct quad{ double a,b,c; }; void readValue(quad&); void showValue(quad&); quad addQuad(quad&,quad&); int main(){ quad Fx; // declare Fx.a=1; //initialize a Fx.b=2; //initialize b Fx.c=3; //initialize c coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.