Why my code is showing segmentation fault?

I am not getting why this code is getting segmentation fault
code - https://ide.codingblocks.com/s/471136

,and

this code is not getting segmentation fault
code - https://ide.codingblocks.com/s/471138

hello @rohitmathur.mathur.6

becuase this program is taking too much memory.
declare both array globally and then it should work

Thanks it is working now,
But why is it working when we are declaring our array globally?

in global scope we can declare large size array compared to function scope.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.