Arrays in expressions as for example when used as arguments are converted to pointers to their first elements.
If you have an array like this
int a[10][10];
that can be rewritten like
int ( a[10] )[10];
that is it is an array of 10 elements of the type int[10[
then in expressions it is converted to the type int ( * )[10]
,
So for example you can write
int ( a[10] )[10] = { {1,2,3}, {4,5,6}, {7,8,9} };
int ( *p )[10] = a;
Thus the function should be declared like
int FindSumLeavingOutRowCol( int arr[][10], int m, int n, int k,int l);
that is the same as
int FindSumLeavingOutRowCol( int ( *arr )[10], int m, int n, int k,int l);
If the compiler supports variable length arrays and the variables m
and n
represent the dimensions (not the ranges) then the function can be also declared like
int FindSumLeavingOutRowCol( int m, int n, int arr[m][n], int k,int l);
or
int FindSumLeavingOutRowCol( int m, int n, int arr[][n], int k,int l);
or like
int FindSumLeavingOutRowCol( int m, int n, int ( *arr )[n], int k,int l);
Otherwise you will need to add two more parameters that specify the ranges apart from the dimensions.
Pay attention to that the variable sum
is not initialized
int sum,i,j;
So the function will have undefined behavior.
And moreover the parameter is declared as having name arr
not a
.
And I hope the function has a return statement something like
return sum;