Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program, satisfying the following requirements. Function float horner(float p[], int n, float x) computes and returns the value of polynomial p[0] x

Write a C program, satisfying the following requirements.

  1. Function float horner(float p[], int n, float x) computes and returns the value of polynomial p[0]xn-1 + p[1]xn-2 + + p[n-2]x1 + p[n-1]*x0 using Horners algorithm.

  2. The main function reads polynomial coefficients from command line arguments in order of p[0] p[1] p[n-2] p[n-1], and stores them in array float p[n]. Then it prompts user for inputing value x, followed by calling function horner(float p[], int n, float x) to evaluate the polynomial and display the result in the format given in testing. Repeats this process until 999 is entered.

public test

 Please enter x value (Ctrl+C or 999 to quit): 0 1.0*0.0^3 + 2.0*0.0^2 + 3.0*0.0^1 + 4.0*0.0^0 = 4.0 Please enter x value (Ctrl+C or 999 to quit): 1 1.0*1.0^3 + 2.0*1.0^2 + 3.0*1.0^1 + 4.0*1.0^0 = 10.0 Please enter x value (Ctrl+C or 999 to quit): 2 1.0*2.0^3 + 2.0*2.0^2 + 3.0*2.0^1 + 4.0*2.0^0 = 26.0 Please enter x value (Ctrl+C or 999 to quit): 10 1.0*10.0^3 + 2.0*10.0^2 + 3.0*10.0^1 + 4.0*10.0^0 = 1234.0 Please enter x value (Ctrl+C or 999 to quit): 999

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Navigating The Supply Chain Maze A Comprehensive Guide To Optimize Operations And Drive Success

Authors: Michael E Kirshteyn Ph D

1st Edition

B0CPQ2RBYC, 979-8870727585

More Books

Students also viewed these Databases questions