answersLogoWhite

0


Best Answer

The correct way in C++ is to not use arrays, but to use vectors instead. You can then pass vector references to your function just as you would pass references to any other object types.

If you choose to use arrays rather than vectors, then you must pass a reference to the first element in each array, along with the number of elements in each array, just as you would have to if you were writing for C rather than C++.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

#include
#include
double avg(int x[][n],int m,int n)
{ int i,j;
double s=0.0;
for(i=0;ifor(j=1;js+=x[i][j];
return(s/m*n);
}
void main()
{ int m=3,n=2;
double mean;
int mt[m][n]={ {1,2},{3,4},{5,6}};
mean=avg(mt,m,n);
printf("\nAverage is:%d",mean);
getch();
}
Source Balagurusamy.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Passing two dimensional arrays into functions in C programming?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Why are matrices used for representation while programming?

Let me correct you: two-dimensional arrays are used in programming to represent matrices. (Matrices are objects of mathematics, arrays are objects of programming.)


How can arrays be used for inter function communication?

The size of a function can be determined from the size of the array. Arrays and functions are both used in computer programming.


What is a multidimentional array?

Arrays having more than one dimension is known as multi-dimensional arrays. Multi-dimensional arrays is also known as arrays-of-arrays.


What is multidimentional array?

Arrays having more than one dimension is known as multi-dimensional arrays. Multi-dimensional arrays is also known as arrays-of-arrays.


One dimensional arrays in foxpro?

;


Give the syntax to declare two dimensional array using array of pointers?

It is not possible to declare a two-dimensional array using an array of pointers in any programming language, but many programming languages support declarations of N-dimensional arrays of pointers.The exact syntax varies with the programming language, and requires support for N-dimensional arrays and pointers. In C, the following declares an array of pointer variables, each implemented as pointer to the generic type "void":void* array_1D[10];The type of the expression array_1D is "void * const."The following example expands on the previous one by declaring a two-dimensional array of "void" pointers:void* array_2D[10][20];The type of the expression array_2D is "void ** const."The last example declares a 3-dimensional array of "void" pointers, which can be seen as a 2-dimensional array of arrays of pointers:void* array_3D[10][20][30];


What is a multi array?

A two-dimensional array is the simplest multi-dimensional array and is implemented as a one-dimensional array where every element is itself a one-dimensional array. We can imagine a two-dimensional array as being a table of rows and columns where every row is an array in its own right. A three-dimensional array is simply a one-dimensional array of two-dimensional arrays, which can be imagined as being an array of tables. Extending the concept, a four-dimensional array is a table of tables. Multi-dimensional arrays may be jagged. That is, a two-dimensional array may have rows of unequal length. Unlike regular arrays, jagged arrays cannot be allocated in contiguous memory. Instead, we use the outer array (the first dimension) to store pointers to the inner arrays. An array of strings (character arrays) is an example of a two-dimensional jagged array.


Can you combine arrays in computer programming?

Yes.


What does a 2 dimensional array do?

A two dimensional array is a one-dimensional array of one-dimensional arrays. That is, just as we can have an array of integers, we can also have an array of integer arrays. This idea can be extended such that we can have an array of two-dimensional arrays (a three-dimensional array), and so on. We typically use a two-dimensional array to represent a table of rows and columns, where each row is a one-dimensional array.


Is it possible to use arrays when using the java programming language?

It is possible to use arrays when employing java programming language. There are many different series of programming choice that can be employed with various end results.


What is 3d array?

Three dimensional arrays are basically multiple two dimensional arrays layered on top of each other.Three dimensional arrays have many uses ex. mapping 3d graphics, calendars (where days are the columns, the weeks are the rows and the months are the layers), or paging methods for reports and recordsets.


Differentiate single dimensional array to double dimensional array?

A single dimensional array is an array of items. A two-dimensional array is an array of arrays of items.