answersLogoWhite

0


Best Answer

if you were to call a function you would write it as:

function(array[][], int pretend, double pretend2);

arrays will always be passed by reference, not by value.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you pass a 2D array in a functions?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Difference between 1D array and 2D arrays?

1d array contains single row and multiple columns and 2d array contains multiple row and multiple columns. 2d array is a collection of 1d array placed one below another,while 1d array is simple a collection of elements.


Flow chart of multiplication of 2d array?

algorithm & flowchrt of 2d matrices


Is there any overhead issues if you make a 2D array arr28 rather than making a 1D array arr16 of size 16 Any memory issues or execution differences between the two?

2D array of size 2x8 and 1D array of size 16


How is an array name interpretedwhen it is passed to a function?

An array is still an array, regardless of how you pass it into functions. It is still an array-type variable at the beginning of a function. However, the function itself may manipulate the array by "imploding" it into a string with a delimiter, using array values with only specific keys, and such.


Subtraction of 2d array in java?

looda le lo mera


How do you pass a one-dimensional array to user-defined functions?

In C++ you would pass a std::array if the array is fixed-length, otherwise you'd use a std::vector. Most object oriented languages will provide some method of passing a self-contained array object to a function. In C and other non-object oriented languages you would pass a reference or pointer to the start address of the array along with a variable indicating the number of valid elements within the array. The array type will determine the size of each element.


When is it better to pass an entire array of data to a function rather than individual elements?

It is better to do this when the function needs to work on the entire array, rather than on individual elements. However, do not pass the array by value; always pass by reference.


How do you access 2D array elements by using single variable?

int main() { int array[3][3]; int i; for(i=0; i <9;i++) { printf("the element is %d\n", array[i/3][i%3]); } return 0; }


What are some of the benefits of using an array as opposed to a medium-sized list of variables?

Arrays exist in contiguous memory, so you can use simple pointer arithmetic to access any element by its offset from the start address (the array name is an alias for the start address), and can pass the entire array to functions as a single entity. Lists of variables are not guaranteed to exist in contiguous memory, and cannot be passed to functions as a single entity.


What is the easiest way to pass arrays as argument in c?

the simple and efficient way to pass an array is pointer to an array like that int (*p)[30] ; // pointer to an array of integer having 30 element


Declaration of two dimentional array in functions?

Possible. void foo (void) { int array [10][20]; ... }


Is it possible to pass a portion of an array to a function?

Yes. Since passing arrays is a special use of call by reference, simply pass the address of the sub array instead of the primary array. int a[10] = { ... }; myfunction (a); // pass the first element's address myfunction (&(a[3]); // pass the fourth element's address