Using C programming language hx x fx fxfx2 fx fx The func
Solution
/*
* C program to evaluate a given polynomial by reading its coefficients
* in an array.
* P(x) = AnXn + An-1Xn-1 + An-2Xn-2+... +A1X + A0
*
* The polynomial can be written as:
* P(x) = A0 + X(A1 + X(A2 + X(A3 + X(Q4 + X(...X(An-1 + XAn))))
* and evaluated starting from the inner loop
*/
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 10
void main()
{
int array[MAXSIZE];
int i, num, power;
float x, polySum;
printf(\"Enter the order of the polynomial \ \");
scanf(\"%d\", &num);
printf(\"Enter the value of x \ \");
scanf(\"%f\", &x);
/* Read the coefficients into an array */
printf(\"Enter %d coefficients \ \", num + 1);
for (i = 0; i <= num; i++)
{
scanf(\"%d\", &array[i]);
}
polySum = array[0];
for (i = 1; i <= num; i++)
{
polySum = polySum * x + array[i];
}
power = num;
printf(\"Given polynomial is: \ \");
for (i = 0; i <= num; i++)
{
if (power < 0)
{
break;
}
/* printing proper polynomial function */
if (array[i] > 0)
printf(\" + \");
else if (array[i] < 0)
printf(\" - \");
else
printf(\" \");
printf(\"%dx^%d \", abs(array[i]), power--);
}
printf(\"\ Sum of the polynomial = %6.2f \ \", polySum);
}
![Using C programming language. h(x) = x - f(x) f\'(x)/[f\'(x)]^2 - f(x) f\ Using C programming language. h(x) = x - f(x) f\'(x)/[f\'(x)]^2 - f(x) f\](/WebImages/24/using-c-programming-language-hx-x-fx-fxfx2-fx-fx-the-func-1062120-1761555010-0.webp)
![Using C programming language. h(x) = x - f(x) f\'(x)/[f\'(x)]^2 - f(x) f\ Using C programming language. h(x) = x - f(x) f\'(x)/[f\'(x)]^2 - f(x) f\](/WebImages/24/using-c-programming-language-hx-x-fx-fxfx2-fx-fx-the-func-1062120-1761555010-1.webp)