I am not getting it properly
Plz understand me dry run of this
to allocate 2D array of size MXN dynamically
first we make array of size M this will store address of n sized m arrays
int *arr=new int[M]
now we make n sized m arrays
for(int i=0;i<m;i++){
arr[i]=new int[n];
}
i hope this picture will help you to understand well
Still I am not getting it
can you tell
which part of this explanation or code you are not getting
for(int i=0;i<m;i++){
arr[i]=new int[n];
}
Sir I am not getting how it is forming n size m arrays
there is loop from i=0 to i<m
so it runs m times and each time it creates an array of size n
in this way it will create n size m arrays
Thanks sir I got this but sir I have also one problem how a[I][j] will be printed
this is same as done in 2D array
for(int i=0;i<m;i++){
//using this loop we are getting address of ith array arr[i]
for(int j=0;j<n;j++){
// now here we are going at jth index in that array and printing it
cout<<arr[i][j]
}
}
i hope this help
if your doubt is resolved please mark it as resolved form your doubt section in the course