Objective Review arrays and functions. Background Functions allow us to break programs up in to smaller...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Objective Review arrays and functions. Background Functions allow us to break programs up in to smaller pieces that are easier to write and more useful because they can be more widely used. Function parameters help to make the functions more flexible and powerful. In previous assignments, we have written functions to evaluate quadratic equations. This assignment will use functions and arrays to evaluate any polynomial. A polynomial in one variable is an expression that can be written in the form y = anx"+an-1-1++a₁x+ao or, equivalently Lab 4 y = 11 1=0 aix Where do... a are the coefficients and n is the order (the highest exponent). A quadratic equation is a polynomial of order 2. A polynomial can be represented by just a list of coefficients which is easily stored in an array. For example, the polynomial 1.2x2x² +1.7x - 3.1 can be represented by the array [1.2, 0, -2.0, 1.7, -3.1). Note: A zero must be used as the coefficient of the missing x³ term. Also, the number of coefficients is one greater than the order (an order 4 polynomial requires 5 coefficients). Assignment 1. Write a function that evaluates a polynomial passed as an array. The parameters should be: a. An array of doubles representing the coefficients. b. An int representing the order of the polynomial. c. A double representing the x value (point at which the polynomial is evaluated). Assignment 1., Write a function that evaluates a polynomial passed as an array. The parameters should be: a. An array of doubles representing the coefficients. b. An int representing the order of the polynomial. c. A double representing the x value (point at which the polynomial is evaluated). 2. Use the following function declaration: double evalPoly(double coeffs [], int order, double x) { } 3. In main(), call your function appropriately to evaluate the following polynomials and print the result to the screen with one decimal place. Remember that you need to pass the order of each polynomial to the function. a. 5x-17, x= 3.1 b. -1.7x -3x² +0.1x+3.5, x= -1.2 Objective Review arrays and functions. Background Functions allow us to break programs up in to smaller pieces that are easier to write and more useful because they can be more widely used. Function parameters help to make the functions more flexible and powerful. In previous assignments, we have written functions to evaluate quadratic equations. This assignment will use functions and arrays to evaluate any polynomial. A polynomial in one variable is an expression that can be written in the form y = anx"+an-1-1++a₁x+ao or, equivalently Lab 4 y = 11 1=0 aix Where do... a are the coefficients and n is the order (the highest exponent). A quadratic equation is a polynomial of order 2. A polynomial can be represented by just a list of coefficients which is easily stored in an array. For example, the polynomial 1.2x2x² +1.7x - 3.1 can be represented by the array [1.2, 0, -2.0, 1.7, -3.1). Note: A zero must be used as the coefficient of the missing x³ term. Also, the number of coefficients is one greater than the order (an order 4 polynomial requires 5 coefficients). Assignment 1. Write a function that evaluates a polynomial passed as an array. The parameters should be: a. An array of doubles representing the coefficients. b. An int representing the order of the polynomial. c. A double representing the x value (point at which the polynomial is evaluated). Assignment 1., Write a function that evaluates a polynomial passed as an array. The parameters should be: a. An array of doubles representing the coefficients. b. An int representing the order of the polynomial. c. A double representing the x value (point at which the polynomial is evaluated). 2. Use the following function declaration: double evalPoly(double coeffs [], int order, double x) { } 3. In main(), call your function appropriately to evaluate the following polynomials and print the result to the screen with one decimal place. Remember that you need to pass the order of each polynomial to the function. a. 5x-17, x= 3.1 b. -1.7x -3x² +0.1x+3.5, x= -1.2
Expert Answer:
Related Book For
Microeconomics An Intuitive Approach with Calculus
ISBN: 978-0538453257
1st edition
Authors: Thomas Nechyba
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
Why do countries respond differently in terms of flexibility and worklife balance to what seem similar economic pressures?
-
A machine fills bottles with 64 fluid ounces of liquid. The quality-control manager determines that the fill levels are normally distributed with a mean of 64 ounces and a standard deviation of 0.42...
-
Find the absolute maximum and absolute minimum values of f on the given interval. f (x) = 12 + 4x - x 2 , [0, 5]
-
Which of the following is an activity not usually associated with forensic accounting and fraud examination consulting and litigation support? 1. A. Assessing fraud risk associated with internal...
-
Howie Stars produces stars for elementary teachers to reward their students. Howie Stars trial balance on June 1 follows: June 1 balances in the subsidiary ledgers were as follows: ¢ Materials...
-
7. 5 What is 11. as an improper fraction? 16 Answer: 17 9 - 8. Which is the difference of 32 32 in lowest terms? 9 18 1 8 32 1 9. 8 5 3 + Which is the quotient of 12 10? 1 18 1 10. What is 25 as a...
-
Use data from the 2017 Economic Census found at https://data.census.gov . About how much was total revenue for all establishments (both establishments subject to and exempt from federal income tax)...
-
Craig Roberts purchased one-half of Ennis Leighton's interest in the Vale and Leighton partnership for $38,000. Prior to the investment, land was revalued to a market value of $185,000 from a book...
-
My neighbor, Jason Chapman, stole a vehicle from my other neighbor, Colette Dewhurst's driveway. While he was driving the car down the road at an excessive rate of speed, Chapman ran into Raymond...
-
9. Staff learning and development records and reports of competency are important documents and must be maintained appropriately. Explain why these records should be kept and describe how they should...
-
What theoretical frameworks do sociologists employ to examine the nexus between technology, digital connectivity, and societal norms, exploring the implications of digital cultures on social...
-
Starbucks has taken customer orders as shown in breakfast.txt file which is in CSV format. The first value in each row is customer name, followed by names of items they have ordered. For example, Sam...
-
4. PT B is a newcomer or a new player in the home appliance electronics industry. As we know that in the home appliance electronics industry itself, there are many brands and good players from both...
-
What do you think?
-
In the text, we demonstrated the equilibrium that emerges when two oligopolists compete on price when there are no fixed costs and marginal costs are constant. In this exercise, continue to assume...
-
Why Vote? Voting is costly. If you vote in person, you have to find your polling place and often stand in line until you get to the voting booth to vote. If you vote by absentee ballot, you have to...
-
Whenever we have modeled political candidates who stand for election, we have assumed that they care only about winning and are perfectly content to change their position in whatever way maximizes...
-
What is EP during Year 1? A. 12,101. B. 6,000. C. 6,000. Mun Hoe Yip is valuing Pure Corporation. Pure is a simple corporation that is going out of business in five years, distributing its income to...
-
How would you evaluate the comments by Simpsons supervisor about not using the IRR and about using the EAA? The supervisor is: A. incorrect about both. B. correct about IRR and incorrect about EAA....
-
A switch from straight-line to accelerated depreciation would: A. increase the NPV and decrease the first year operating income after taxes. B. increase the first year operating income after taxes...
Study smarter with the SolutionInn App