1.

How will you pass two dimensional array to a function explain with example.

Answer»

Passing 2”D array to a function

#include<iostream>

using namespace std;

void display (int n[3][2])

int main()

{

int num[3][2] = { {3,4},{9,5},{7,1} };

display(num);

return 0;

}

void display(int n[3][2]);

cout<<“\n  Displaying Values”<<end1;

for(int i=0;i<3;i++)

{

for(int j=0;i<2;j++)

{

cout<<n[i][j]<<" ";

}

cout<<end1<<emd1;

}

}

Output:

Displaying Values

3 4

9 5

7 1



Discussion

No Comment Found