Since you said you got a Segfault and a core file, I'll assume you're running on a Linux system. It looks like you've got a stack-smashing issue (basically, you're allocating too much data on the stack). For instance,
int N = 1024;
Assuming an int is 4 bytes, we have 1024 * 1024 * 4 = 4 MB just for this one array. Now you have 3 such arrays declared x, y and z. Therefore total stack needed for just these three arrays is 4 * 3 = 12 MB. And we also need stack space for the remaining variables as well (i, j, k, r) as well as for function calls. So we'll need stack somewhat more than 12 MB to run this program.
Now if you go to your linux system and type:
This shows the max. amount of stack assigned to your programs by default. On my system, it says:
mb@motorhead:~$ ulimit -s
i.e. 8MB max. stack is allocated to my program when it starts up. This is less than the min. of 12 MB+ stack that the program needs.
Now if I change the max. amount to something else (such as 16384 (i.e.) 16 MB), the code runs without segfault.
mb@motorhead:~/cpp$ ulimit -s 16384
.... runs all the way without segfault ....
Of course the result will be nonsense, since you haven't set y or z, but I'll assume you knew that already.
Hope this helps.