Professional Documents
Culture Documents
Na Asg 2 053 035
Na Asg 2 053 035
NA ASG # 2
Code
// NA_ASG__2_053_035
#include<iostream>
using namespace std;
int create_difference_table()
{
float x[20], f[20][20];
int i, j, size;
/*Difference Table*/
for (i = 1; i < size; i++)
{
for (j = 0; j < size - i; j++)
{
f[j][i] = f[j + 1][i - 1] - f[j][i - 1];
}
}
//Error finding
bool check = false;
i = 3;
j = 0;
{
//4th
if (f[i][j] >= 0 && f[i][j+1] <0 && f[i][j + 2] >= 0 && f[i][j + 3]<0
&& f[i][j + 4] >=0)
August 31, 2022 [NA ASSIGNMENT 2 (035,053)
{
check = true;
if (check = true)
{
cout << endl;
cout << "-----------Error is in 4th order--------------"
<< endl;
return 0;
}
}
if (f[i][j+1] >= 0 && f[i][j + 2] < 0 && f[i][j + 3] >= 0 && f[i][j +
4] < 0 && f[i][j + 5] >= 0)
{
check = true;
if (check = true)
{
cout << endl;
cout << "-----------Error is in 4th order--------------"
<< endl;
return 0;
}
}
//3rd
i = 2;
if (f[i][j] >= 0 && f[i][j + 1] < 0 && f[i][j + 2] >= 0 && f[i][j + 3]
< 0)
{
check = true;
if (check = true)
{
cout << endl;
cout << "-----------Error is in 3rd order--------------"
<< endl;
return 0;
}
}
if (f[i][j+1] >= 0 && f[i][j + 2] < 0 && f[i][j + 3] >= 0 && f[i][j +
4] < 0)
{
check = true;
if (check = true)
{
cout << endl;
cout << "-----------Error is in 3rd order--------------"
<< endl;
return 0;
}
}
if (f[i][j+2] >= 0 && f[i][j + 3] < 0 && f[i][j + 4] >= 0 && f[i][j +
5] < 0)
{
check = true;
if (check = true)
{
cout << endl;
cout << "-----------Error is in 3rd order--------------"
<< endl;
return 0;
August 31, 2022 [NA ASSIGNMENT 2 (035,053)
}
}
if (f[i][j+3] >= 0 && f[i][j + 4] < 0 && f[i][j + 5] >= 0 && f[i][j +
6] < 0)
{
check = true;
if (check = true)
{
cout << endl;
cout << "-----------Error is in 3rd order--------------"
<< endl;
return 0;
}
}
//2nd
i = 1;
if (f[i][j] >= 0 && f[i][j + 1] < 0 && f[i][j + 2] >= 0)
{
check = true;
if (check = true)
{
cout << endl;
cout << "-----------Error is in 2nd order--------------"
<< endl;
return 0;
}
}
if (f[i][j+1] >= 0 && f[i][j + 2] < 0 && f[i][j + 3] >= 0)
{
check = true;
if (check = true)
{
cout << endl;
cout << "-----------Error is in 2nd order--------------"
<< endl;
return 0;
}
}
if (f[i][j+2] >= 0 && f[i][j + 3] < 0 && f[i][j + 4] >= 0)
{
check = true;
if (check = true)
{
cout << endl;
cout << "-----------Error is in 2nd order--------------"
<< endl;
return 0;
}
}
if (f[i][j=3] >= 0 && f[i][j + 4] < 0 && f[i][j + 5] >= 0)
{
check = true;
if (check = true)
{
cout << endl;
cout << "-----------Error is in 2nd order--------------"
<< endl;
August 31, 2022 [NA ASSIGNMENT 2 (035,053)
return 0;
}
}
if (f[i][j+4] >= 0 && f[i][j + 5] < 0 && f[i][j + 6] >= 0)
{
check = true;
if (check = true)
{
cout << endl;
cout << "-----------Error is in 2nd order--------------"
<< endl;
return 0;
}
}
if (f[i][j+5] >= 0 && f[i][j + 6] < 0 && f[i][j + 7] >= 0)
{
check = true;
if (check = true)
{
cout << endl;
cout << "-----------Error is in 2nd order--------------"
<< endl;
return 0;
}
}
void main()
{
create_difference_table(); // with error finding
}
output
August 31, 2022 [NA ASSIGNMENT 2 (035,053)
+ (e)
- (-4e)
+ (6e)
- (e)
X----------X----------X