Question: Program hint is given below program statement Problem Statement: Write a C program to compute the polynomial functional value at any value of x given

Program hint is given below program statement

Problem Statement: Write a C program to compute the polynomial functional value at any value of x given the polynomial f(x) with its coefficients in an array a[ ]. The order of the polynomial and the coefficients are input by the user. Limit the order value to 10.

what the Program#5 looks like:

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

int main()

{

int n=2; double xgiven = 2.5; int a[3]={-2, 3, 2}; double func; /* initial line */

func = a[2]; /* intitalize func value */

int j = n-1;

/* apply Horners scheme using for loop */

printf(" j = %d\n",j);

printf("xgiven = %f ",xgiven);

printf("a[j] = %d\n",a[j]);

printf("func = %f ", func);

func=func*xgiven+a[j];

j = n-2;

/* apply Horners scheme using for loop */

printf(" j = %d\n",j);

printf("xgiven = %f ",xgiven);

printf("a[j] = %d\n",a[j]);

printf("func = %f ", func);

func=func*xgiven+a[j];

//}

// func = a[0]+a[1]*xgiven+a[2]*xgiven*xgiven;

printf("The function value of quadratic polynomial f(x) at x=%f is = %f ", xgiven,func);

for(j = n-1; j >= 0; j--) {

func=func*xgiven+a[j];

}

printf("The function value of quadratic polynomial f(x) at x=%f is = %f ", xgiven,func);

return 0;

}

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!