Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!