Question
In C++: Default arguments: Write a C++ function Poly that will return the value of a 1st 5th order polynomial of the form: Inputs to
In C++: Default arguments: Write a C++ function Poly that will return the value of a 1st 5th order polynomial of the form: Inputs to the function should include x and the polynomial coefficients, A0 A5. The function should use default values of 0 for A2 A5 so that it will work with polynomials that are 1st order, 2nd order, 3rd order, 4th order, or 5th order and unused higher-order coefficients do not need to be listed in the function call.
Examples: Function Poly could be used to evaluate 1st, 2nd, and 5th order polynomials as follows: y = Poly(1,2,3); (answer: y = 2+3x = 2+3(1) = 5) y = Poly(2,5,4,3); (answer: y = 5+4x+3x2 = 5+4(2)+3(2)2 = 25) y = Poly(2,3,4,5,6,7,8); (answer: y = 3+4x+5x2+6x3+7x4 +8x5 = 447)
A) Write function Poly as described above.
B) Write a main function that prompts the user to enter the order (1-5) and then prompts the user to enter the correct number of coeffients and the value of x. The main program should then call function Poly to calculate the output and display the result.
C) Test the program for the 3 cases above as well as for 3rd and 4th order polynomials for any values you choose. Check the values by hand (show the calculations) to insure that they are correct.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started