#include<stdio.h>
#include<conio.h>
#define col
4
#define row
4
void main()
{
int i,n,j;
float ax[row+1],
ay[col+1],diff[row+1][col+1],x,p,ya1,ya2,ya3,ya4,ya,ha;
clrscr();
printf("Enter thae value of
n:");
scanf("%d",&n);
printf("\n Enter thae values of
X and Y:\n");
for(i=0; i<=n; i++)
{
scanf("%f
%f",&ax[i],&ay[i]);
}
printf("Value of X:");
scanf("%f",&x);
ha=ax[1]-ax[0];
for(i=0; i<=n-1; i++)
diff[i][1]=ay[i+1]-ay[i];
for(j=2; j<=row; j++)
for(i=0; i<=n-j; i++)
diff[i][j]=diff[i+1][j-1]-diff[i][j-1];
p=(x-ax[0])/ha;
ya1=p*diff[0][1];
ya2=p*(p-1)*diff[0][2]/2;
ya3=p*(p-1)*(p-2)*diff[0][3]/6;
ya4=p*(p-1)*(p-2)*(p-3)*diff[0][4]/24;
ya=ay[0]+ya1+ya2+ya3+ya4;
printf("%f",ya);
getcha();
}
No comments:
Post a Comment