The problem is as follows, Write a program to read in an array containing the co-efficients of the polynomial and compute the value of the polynomial for a given value of x.
e.g :By Horners method 3+4x+5x^2+6x^3+7x^4 can be written as;
3+(4+(5+(6+7x)x)x)x
In my understanding this is like;
a = 6+7x
b = 5+ ax
c = 4+ bx
d= 3+cx
where 6 = a(n-1), 7 = a(nx), 5 =a(n-2) , 4 =(a n-3) etc
this is my code so far and i really really am lost as to where to go from here and finish the code.
this is my code so far and i really really am lost as to where to go from here and finish the code.-----------------------------------------------------------------------------------------------------
CODE
------------------------------------------------------------------------------------------------------
Code:
#include<stdio.h>
#include<math.h>
#define MAX_SIZE 50
void main (void);
void main(void)
{
int n,i;
double coeffs[MAX_SIZE],x,result;
printf("enter order of equation");
scanf("%d",&n);
printf("enter the value of x/n");
scanf("%lf",&x);
for(i=n-1;i>=0; i--)
{
printf("enter coeffs[%d]:", i+1);
scanf("lf%",&coeffs[i]);
}
result =(x*coeffs[i]);
printf("the array elements are %d,coeffs[i]);
for(i=n-1;i>=0;i--)
{
n+(n-1)x
}