Passing 2D array as a parameter to a function

When we pass 2D array as a parameter to a function then why do we need to put the column value next to it?

Also while declaring a 2D array we have to do so. Why?

Answer to both is :
int arr[][]={1,2};
now how the compiler knows if its 2x1 or 1x2

So why only column size has to be mentioned. Why can’t we mention only teh row size?

int arr[2][]={1,2,3,4,5,6,7,8};
now how the compiler knws if there are 5 elements in 1 row or 8 or xyz…
He can’t just simply dived total elements between different rows.

Hey @Shivam01
Do u have any doubt in this or shall I close it ?

okky thank you for explanation

1 Like