# Backward Difference Table Generation Using C++ with Output

While interpolating unknown value of dependent variable corresponding to some independent variable using Newton's Backward Interpolation formula for equispaced data, we need to construct Backward Difference Table. In this article, we are going to generate backward difference table using C++ programming language and output of program is also provided.

## C++ Program for Generating Forward Difference Table

``````
#include<iostream>

using namespace std;

int main()
{
float x, y;
int i,j, n;

/* Input Section */
cout << "Enter number of data? " << endl;
cin >> n;

cout << "Enter data: " << endl;
for(i = 0; i < n ; i++)
{
cout << "x[" << i << "] = ";
cin >> x[i];
cout << "y[" << i <<"] = ";
cin >> y[i];
}

/* Generating Backward Difference Table */
for(i = 1; i < n; i++)
{
for(j = n-1; j > i-1; j--)
{
y[j][i] = y[j][i-1] - y[j-1][i-1];
}
}

/* Displaying Forward Difference Table */
cout << endl << "BACKWARD DIFFERENCE TABLE" << endl;

for(i = 0; i < n; i++)
{
cout << x[i];
for(j = 0; j <= i ; j++)
{
cout << "\t" << y[i][j];
}
cout << endl;
}

return 0;
}

``````

## Backward Difference Table Using C++ Output

```
Enter number of data?
5
Enter data:
x = 20
y = 33
x = 30
y = 71
x = 40
y = 118
x = 50
y = 163
x = 60
y = 188

BACKWARD DIFFERENCE TABLE
20      33
30      71      38
40      118     47      9
50      163     45      -2      -11
60      188     25      -20     -18     -7

```