Why i am getting run time error on declaring the matrix as 0

With matrix initialize as 0 :-CodeChef: Practical coding for everyone

With matrix declared only:- CodeChef: Practical coding for everyone

I think when you just declared the matrix the memory is not allocated to the program.

When you initialize it with {0} then the program is trying to assign n * n * (size of int) memory. As n is very large, it will fail to assign that memory leading to runtime error.