I am trying to pass a 2D array of variable size to a function to print it.but the code doesn\'t show the exact result of sum.
this is the code:
#include
There is no technical problem with passing, but in sum_arr,
your variable sum does not start at 0 (but some strange value).
You should pass the exact size of the second dimension of the array to the function, not COLL. change it to m (or n, whatever)
It passes the number 5 to the function while the number should be 3 :) How ever, this is not the main reason that you're code is not working, just a suggestion.
Initialize the variable sum. It will make your code work. e.g. sum = 0;
If you don't initialize it, you won't get any compile errors, but it points to a location of memory and reads thing been there before (not a valid amount) and uses it as the initial amount of that for sum.
So your array is being added to a non-valid amount, that's why your code doesn't work.
You have to initialize sum to zero in sum_arr function.