Array Parameter

Why in printmatrix(int a[][10]) is passed. why it doesnt have any parameter ? If we pass a value it takes only as decided by value so why no value their

Hello @dhruvtrehan45,

Your doubt is not clear. Can you please explain what you are trying to ask.

BTW, printmatrix() function is created to print the 2D array that we are passing as a parameter to the function.
In printmatrix(int a[][10]) function, the 2D array a[][10] is itself a parameter to the function.

When we pass 2D array as a parameter, we have to specify the number of columns it would have.
Also, arrays are by default passed reference.

Which parameter are you talking about?

I want to ask why their is no value in no.of rows of a[][10]?
Why what changes it bring to code ?

Hello @dhruvtrehan45,

You need not to specify the no. of rows.
That is something optional.
The compiler will compute that itself.
So, you can pass the # of rows but that won’t make a difference.

It’s the same you do for 1D array:
Both printarray(int a[]) or printarray(int a[10]) are correct.

Hope, this would help.
Give a like if you are satisfied.

1 Like

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.