Saturday, October 22, 2011

a c program for polynomial

#include <stdio.h>
#include <conio.h>

int main()
{
    int n=9, x, i, j, p ;
    printf("Enter the value of x: ");
    scanf("%d", &x);
    int co[n];
    printf("Enter the coefficients \n");
    for(i=0; i<n; ++i)
       {
             scanf("%d", &co[i]);
       }
    p = co[n-1];
   
    for(j=n-1; j>0; --j)
       {
          p = co[j-1] + x*p;
       }
    printf("%d", p);
   
    getch();
    return 0;
}

No comments:

Post a Comment