i didnt understand how the 2D array is made and implemented in the given lecture
Passing 2D array as an argument
hi @sy7176442_ca8a8991a7ddc322
#include <iostream>
using namespace std;
int main() {
int n,m;
cin>>n>>m; // n is no of rows and m is no of columns
int arr[n][m]; //decalring a 2D array of size n*m
for(int i=0;i<n;i++){ //reading input from user
for(int j=0;j<m;j++){
cin>>arr[i][j];
}
}
for(int i=0;i<n;i++){ //printing the 2D array
for(int j=0;j<m;j++){
cout<<arr[i][j]<<" ";
}
cout<<endl;
}
}
hope it clears ur doubt…
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.