#include<stdio.h>
#include<conio.h>
#define DEGREE 10
void main()
{
 int n,i,j;
 float x,p[DEGREE+1],f[DEGREE+1],sum=0,product;
 clrscr();
 printf("Enter the value of x and the degree of the polynomial:");
 scanf("%f%d", &x,&n);
 printf("Enter %d values of x// and their corresponding functional values//:\n",n+1);
 for(i=1;i<=n+1;i++)
 scanf("%f", &p[i]);
 printf("Enter the corresponding functional values of x:");
 for(i=1;i<=n+1;i++)
 scanf("%f", &ff[i]);
 for(i=1;i<=n+1;i++)
 {
  product=1;
  for(j=1;j<=n+1;j++)
  {
   if(j!=i)
   product=product*((x-p[j])/(p[i]-p[j]));
  }  /*for loop for j ends*/
  sum=sum+(f[i]*product);
 } /*loop for i ends*/
 printf("The sum for x=%f is %f", x,sum);
 getch();
}
