I have two functions. Both give the same result. I understand how the first function works but what happens on the second function?
Code:
/* function definition */
int DataAdd1(int list[][5], int max1, int max2)
{
int i,j;
int sum=0;
for(i=0; i<max1; i++)
for(j=0; j<max2; j++)
sum +=list[i][j];
return sum;
}
/* function defintion*/
int DataAdd2(int *list, int max1, int max2)
{
int i,j;
int sum =0;
for(i=0; i<max1; i++)
for(j=0; j<max2; j++)
sum +=*(list +i*max2 +j);
return sum;
}
how does this
Code:
sum +=*(list +i*max2 +j);
come out to equal this i dont get it.