Sum of all submatrix

I corrected the code as you said but still it is not working.
it does not print sum

Hi @aslesha.j7,
here is d updated code.


in the end, when li==0,lj==0,etc and u were trying to find a[li-1], it was giving error.
Hope dis helps.

I got it but did you change anything else as Im getting a diff ans on coding blocks ide and on my compiler

@aslesha.j7
i made changes at
1)
for(int li=1;li<=m;li++)
{
for(int lj=1;lj<=n;lj++)
{
2)
at top declared
int a[100][100];
memset(a,0,sizeof a);

what is the function of memset and why would you increase the array size

@memset assign a common value to the whole array(common value=as specified by user)
i just increased the size of array for inputs with n>10.
Hope dis helps

I still didnt understood memset and also it is not working on my compiler

@aslesha.j7
We can use memset() to set all values as 0 or -1 for integral data types also. It will not work if we use it to set as other values.
try running dis.
include d necessary header files.
int a[5];
memset(a, 0, sizeof(a));
for (int i = 0; i < 5; i++)
cout << a[i] << " ";
cout << endl;

what is the nned of using memset. Cant we do without it as Im not able to understand it

what is the need of using memset. Cant we do without it as Im not able to understand it

@aslesha.j7
you can do the questiion without using memset also.

without memset the answer is different

@aslesha.j7


refer to dis

okay thank you I got it