#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<math.h>
void main()
{
int n;
int i,j;
float ax[10];
float ay[10];
float x;
float y=0;
float h;
float p;
float diff[20][20];
float y1,y2,y3,y4;
clrscr();
printf("\t\t!! NEWTON GRAGORY FORWARD INTERPOLATION FORMULA!!\n");
printf("\t\t By KRISHAN \t\t\n");
printf("\t\t enter the no of terms ->");
scanf("%d",&n);
printf("\n\t\t enter the value in form of x->");
for(i=0;i<n;i++)
{
printf("\n\t\t enter the value of x%d->",i+1);
scanf("%f",&ax[i]);
}
printf("\n\t\tenter the value in the form of y->");
for(i=0;i<n;i++)
{
printf("\n\t\tenter the value of y %d->",i+1);
scanf("%f",&ay[i]);
}
printf("\n\t\tenter the value of x for");
printf("\n\t\t which u want the value of y->");
scanf("%f",&x);
h=ax[1]-ax[0];
for(i=0;i<n-1;i++)
diff[i][1]=ay[i+1]-ay[i];
for(j=2;j<=4;j++)
for(i=0;i<n-j;i++)
diff[i][j]=diff[i+1][j-1]-diff[i][j-1];
do
{
i++;
}
while(ax[i]<x);
i--;
p=(x-ax[i])/h;
y1=p*diff[i-1][1];
y2=p*(p+1)*diff[i-1][2]/2;
y3=p*(p+1)*(p-1)*diff[i-2][3]/6;
y4=(p+2)*(p+1)*p*(p-1)*diff[i-3][4]/24;
y=ay[i]+y1+y2+y3+y4;
printf("\n\t\t when x=%6.4f,y=%6.8f",x,y);
printf("\n\n\n\t\t\t!! PRESS ENTER TO EXIT!!");
getch();
}
/program for newton backward interpolation formula
#include <stdio.h>
#include <conio.h>
#include <math.h>
#define pf printf
#define sf scanf
#define maxn 100
#define order 4
void main()
{
float ax[maxn+1],ay[maxn+1],diff[maxn+1]
[order+1],nr=1,dr=1,x,p,h,yp;
int n,i,j,k;
clrscr();
pf("enter the value of n\n");
sf("%d",&n);
pf("enter the values in form x,y\n");
for(i=1;i<=n;i++)
{sf("f",&ax[i],&ay[i]);}
pf("enter the value of x for which value of y is wanted\n");
sf("%f",&x);
h=ax[2]-ax[1];
for(i=n;i>=1;i--)
{diff[i][1]=ay[i]-ay[i-1];}
for(j=2;j<=order;j++)
{
for(i=n;i>j;i--)
{diff[i][j]=diff[i][j-1]-diff[i-1][j-1];}
}
i=n;
p=(x-ax[i])/h;
yp=ay[i];
for(k=1;k<=order;k++)
{
nr*=p+k-1;
dr*=k;
yp+=(nr/dr)*diff[i][k];
}
pf("when x =%f\t y= %f",x,yp);
getch();
}
//program for newton backward interpolation formula
#include <stdio.h>
#include <conio.h>
#include <math.h>
#define pf printf
#define sf scanf
#define maxn 100
#define order 4
void main()
{
float ax[maxn+1],ay[maxn+1],diff[maxn+1]
[order+1],nr=1,dr=1,x,p,h,yp;
int n,i,j,k;
clrscr();
pf("enter the value of n\n");
sf("%d",&n);
pf("enter the values in form x,y\n");
for(i=1;i<=n;i++)
{sf("f",&ax[i],&ay[i]);}
pf("enter the value of x for which value of y is wanted\n");
sf("%f",&x);
h=ax[2]-ax[1];
for(i=n;i>=1;i--)
{diff[i][1]=ay[i]-ay[i-1];}
for(j=2;j<=order;j++)
{
for(i=n;i>j;i--)
{diff[i][j]=diff[i][j-1]-diff[i-1][j-1];}
}
i=n;
p=(x-ax[i])/h;
yp=ay[i];
for(k=1;k<=order;k++)
{
nr*=p+k-1;
dr*=k;
yp+=(nr/dr)*diff[i][k];
}
pf("when x =%f\t y= %f",x,yp);
getch();
}
forward slash - division operator backward slash - special character (e.g. \n - newline) in C strings
c program was introduced in the year 1972 by Dennis RitchieNo, it was the C language, not the C program.
how to create a c program for left factoring.
C-SPAN Bus program was created in 1993.
No you can't. main() is the entry point of a C program where execution starts. Only a single main() can exist in a C program. A program with 2 mains wil not even compile successfully.
It will weigh between 355.4 Newtons (at 100 deg C) and 370.8 Newtons (at 4 deg C).
backward
Courtney
forward slash - division operator backward slash - special character (e.g. \n - newline) in C strings
it is actually a D and a backward C. But its called DC its a skater brand.
the features of a C program
c program was introduced in the year 1972 by Dennis RitchieNo, it was the C language, not the C program.
I think it is 'execution of a C program'.
how to create a c program for left factoring.
what are the parts of C language program
find the program in c-pgms.blogspot.com
Yes, you can program games with C++.