### MULTIARRAY Functions

Hi again guys,

I'm having trouble to compile my program as there are some errors & i dun really understand wad the compiler output really mean for.

If u copy&paste my code on ur compiler u could see the highlighted syntax.

for array,when passing into function..normally is <datatype><functionname><int[],array_size> but how about multi array?

 ``1234567891011121314151617181920212223242526272829303132333435363738`` `````` #include using namespace std; void sum(int [],int [],int []); int main() { int max1[3][3]={{3,4,2},{2,6,8},{7,3,9}}; int max2[3][3]; int max3[3][3]; for(int a=0;a<3;a++) { for(int b=0;b<3;b++) { cout<<"Enter value:\n"; cin>>max2[a][b]; } } sum(int max1,int max2,int max3); cout<<"Your product of addition is:"<
I don't think you have the slightest clue of what you're doing.

From the looks of it, you're trying to perform matrix addition without knowing how multidimensional arrays work.

Just look at line 21; what are you trying to do? Print the address of max3?

Do some extensive reading, and then take a look at your fixed code:

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950`` ``````#include using namespace std; void sum(int[][3], int[][3], int[][3]); int main() { int max1[3][3] = { { 3, 4, 2 }, { 2, 6, 8 }, { 7, 3, 9 } }; int max2[3][3]; int max3[3][3]; for(int a = 0; a < 3; a++) { for(int b = 0; b < 3; b++) { cout << "Enter value:" << endl; cin >> max2[a][b]; } } sum(max1, max2, max3); cout << "Your product of addition is:" << endl; for(int a = 0; a < 3; a++) { for(int b = 0; b < 3; b++) { cout << max3[a][b] << ' '; } cout << endl; } cin.get(); return 0; } void sum(int max1[][3], int max2[][3], int max3[][3]) { for(int c = 0; c < 3; c++) { for(int d = 0; d < 3; d++) { max3[c][d] = max1[c][d] + max2[c][d]; } } }``````
thks,so for the void function at line 41.

For example,int max1[][3]..we juz nid to pass in columns?
Topic archived. No new replies allowed.