Subscribe Us

Responsive Advertisement

Advertisement

17.Newton’s forward difference formula:

 17.Newton’s forward difference formula:

by ujjal roy



#include<bits/stdc++.h>

using namespace std;

int main()

{

    cout<<"Enter Number of element ";

    int n,i,j;

    cin>>n;

    double x[n],y[n][n];

    for(i=0;i<n;i++)

    {

        cout<<"Enter x and y : ";

        cin>>x[i];

        cin>>y[i][0];

    }

    for(j=1;j<n;j++)

    {

        for(i=0;i<n-j;i++)

        {

            y[i][j]=y[i+1][j-1]-y[i][j-1];

        }

    }

    for(i=0;i<n;i++)

    {

        cout<<x[i]<<"\t";

        for(j=0;j<n-i;j++)

        {

            cout<<y[i][j]<<"\t";

        }

        cout<<endl;

    }

    return 0;

}


Post a Comment

0 Comments