I wanted to know if this is one 2D array or 3 separate ones due to the for loops, not quite sure?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
using namespace std;

int main()
{
        int arr[3][3]={{1,2,3},{4,5,6},{7,8,9}};
        for(int i=0; i<=2; i++)
           for(int j=0; j<=2; j++)
           {
               cout<<arr[i][j]<<" ";
           }
               cout<<endl;
        for(int i=0; i<=2; i++)
           for(int j=0; j<=2; j++)
           {
               cout<<arr[j][i]<<" ";
           }
               cout<<endl;
        for(int i=2; i>=0; i--)
           for(int j=2; j>=0; j--)  
           {
               cout<<arr[i][j]<<" ";
           }
               cout<<endl;
return 0;   
}
      
it's 2D array.
but in memory is stored as 3 seperate arrays: stored one behind other.
it's stored in memory in same way as u have initialize it on line 6.
because the question said that this does not involve three separate 2D arrays; there should be only one 2D array, so i wanted to make sure that its not separate 2D arrays
Topic archived. No new replies allowed.