Sum of all sub matrices of a given matrix

Please explain line 20;( why we have used new)

actually there is a mistake
int *arr=new int *[n] is wrong
correct is int **arr=new int * [n]
correct one is

sir has corrected it later

new is used to allocate dynamic memory

now let me explain this correct one
we have to make 2D array dynamically
2D array is arrays of arrays
so we make an array of size m which holds the address of next n arrays

i hope this picture will help you to understand well

Screenshot from 2020-05-03 11-25-10

i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask

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.