Write a C program to evaluate the given polynomial P(x)=AnXn + An-1Xn-1 + An-2Xn-2+… +A1X + A0, by reading its coefficents into an array.A Polynomial is a mathematical expression involving a sum of powers in one or more variables multiplied by coefficients. Read more about C Programming Language .

/***********************************************************

* You can use all the programs on www.c-program-example.com

* for personal and learning purposes. For permissions to use the

* programs for commercial purposes,

* contact [email protected]

* To find more C programs, do visit www.c-program-example.com

* and browse!

*

* Happy Coding

***********************************************************/

#include <stdio.h>

#include <conio.h>

#include <stdlib.h>

#define MAXSIZE 10

voidmain()

{

int a[MAXSIZE];

int i, N,power;

float x, polySum;

clrscr();

printf("Enter the order of the polynomialn");

scanf("%d", &N);

printf("Enter the value of xn");

scanf("%f", &x);

/*Read the coefficients into an array*/

printf("Enter %d coefficientsn",N+1);

for (i=0;i <= N;i++)

{

scanf("%d",&a[i]);

}

polySum = a[0];

for (i=1;i<= N;i++)

{

polySum = polySum * x + a[i];

}

power = N;

/*power--;*/

printf("Given polynomial is:n");

for (i=0;i<= N;i++)

{

if (power < 0)

{

break;

}

/* printing proper polynomial function*/

if (a[i] > 0)

printf(" + ");

else if (a[i] < 0)

printf(" - ");

else

printf (" ");

printf("%dx^%d ",abs(a[i]),power--);

}

printf("nSum of the polynomial = %6.2fn",polySum);

}

Array In C Simple C ProgramsYou can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com