Error in ouput. "Sum of all submatrix - Approach 2"

Every time i run program, I get different result…
please tell where i mistaken.

Code Link:

please respond as soon as possible…

@alok.maurya
hello Alok,

handle the corner cases when ti-1 ==-1 or tj-1 ==-1 .
as we cannot access negative indices.

you can refer this code for the same -> https://ide.codingblocks.com/s/195084