/* Program for Newton's forward diference formula*/
#include<stdio.h>
#include<conio.h>
void main()
{
 int i,j,n,m;
 float p,h,sum,product,x[10],f[10],u,D(float,int);
 clrscr();
 printf("Enter the value of x and the degree of the polynomial one by one: ");
 scanf("%f%d", &p,&n);
 printf("Enter %d equally spaced values of x and their corresponding ",n+1);
 printf("functional values one by one\n  ");
 for(i=1;i<=n+1;i++)
 scanf("%f%f",x[i],f[i]);
 h=x[2]-x[1];   u=(p-x[1])/h;
 sum=f[1];
 for(m=1;m<=n;m++)
 {
  product=1;
  for(j=1;j<=m-1;m++)
  product=product*(u-j)/(j+1);
  sum=sum+(D(float[],int)*product);
 }
 printf("The value of the polynomial for x=%f is %f", p,sum);
 getch();
}

float D(float f[10],int m)
{
 D(float,int m)= D(float,m+1)-D(float,m);
 return ;
}