You are using a fixed array, so if N is greater than 10 the result will most likely be a SEGV fault. You should allocate the array with the
new
statement after you have first accepted the value of N. Something like:
int N;
cin >> N;
int* arr = new int[N];
for(int i=0; i < N; i++)
{
cin >> arr[i];
}
You also need to check the contents of your input file to make sure it contains valid data.