Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective Review arrays and functions. Background Functions allow us to break programs up in to smaller pieces that are easier to write and more

Objective Review arrays and functions. Background Functions allow us to break programs up in to smaller Assignment 1., Write a function that evaluates a polynomial passed as an array. The parameters should be: a.

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++ax+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

Step by Step Solution

3.39 Rating (152 Votes )

There are 3 Steps involved in it

Step: 1

Heres the C code that implements the re... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics An Intuitive Approach with Calculus

Authors: Thomas Nechyba

1st edition

538453257, 978-0538453257

More Books

Students also viewed these Programming questions