You have declared the variable N and not initialized it so it takes garbage value. After that you have declared the array with size N which i am really doubtful about.
According to me you should always declare your array after taking the size input. I did that and your code runs fine.
So i might have not told you the reason of runtime error but i have definitely told you the solution i.e. declare the array after taking N as input.
Why you people don’t provide question links. It really helps alot to understand the code after knowing what its purpose is to do and yaa please provide solution link or post your solution using codesample option in the editor
I believe this feature was introduced in C99 if i correctly remember my programming with C lectures
I am not so sure though but declaring array after the size has been taken input seems logical to me and more importantly it always works. :xD