I am learning C++ and this is my first question for martix array in c++. I am getting Process returned -1073741571 (0xC00000FD) in terminal window. When Tried running it after removing the #define N 1000 then my code gave me the correct result. I want to know why it is not executing the code for #define constant. This is the code.
#include <iostream>
#include <cmath>
#define N 1000
using namespace std;
#function to give components of Vector A in different dimensions.
double vectorA (int n)
{
double ai = pow(-1, n)*2*n;
return ai;
}
#function to give components of Vector B in different dimensions.
double vectorB (int n)
{
double bi = pow(-1, n)*n/2;
return bi;
}
int main()
{
int n;
cin >> n;
#arr is the cross product vector.
double arr [N][N];
#vector 1 and vector 2 using components defined by function A and B.
double arr1 [N];
double arr2 [N];
#initialising the vector 1 (arr1)
for (int i = 0; i < n; i++)
{
arr1 [i] = vectorA (i);
}
#initialising the vector 2 (arr2)
for (int i = 0; i < n; i++)
{
arr2 [i] = vectorB (i);
}
#initialising the cross product vector (arr).
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
arr [i][j] = arr1 [i] * arr2 [j];
}
}
int dot = 0;
#dot product of vector 1 and vector 2.
for (int i = 0; i < n; i++)
{
dot += arr1 [i] * arr2 [i];
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
cout << arr [i][j] << " ";
}
cout << endl;
}
cout << dot << endl;
return 0;
}