In this question,I have declared all the elements of dp array as 0 but it is printing some other values in the first line

Output of dp array:
0 32661 1024 0 -1902239296
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

Link of program:https://ide.codingblocks.com/s/327962

Please tell me whats wrong in this code.Why first line of dp array is printing abrupt value

int dp[n+4][n+4]={0};
This only initializes the first row as 0.

but it is not initializing the first row as 0

it is initializing rows other then first row as 0.What is the logic in this

Then possibly, it is compiler dependant. On my compiler the first row becomes 0.

Anyway, it is incorrect to do so, C++ guarantees this to work only in case of 1D arrays.