0

How to write a 2 dimensional array of the form a[3][3]

Program in c or c++

13th Sep 2019, 5:15 AM
Arthur Steve
Arthur Steve - avatar
5 Answers
+ 1
Use a double for loop, each over the length of your dimensions, and fill the slots of your array one by one.
13th Sep 2019, 8:12 AM
HonFu
HonFu - avatar
+ 1
Static way int a[3][3] = { {0,1,2}, {1,2,3}, {2,3,4} };
13th Sep 2019, 8:58 AM
Talha Altınel (The Last Sith Lord)
Talha Altınel (The Last Sith Lord) - avatar
+ 1
Non static way int a[3][3]; for(int i = 0; i <3; i++) { for(int j = 0; j<3; j++) { a[i][j] = i + j; } }
13th Sep 2019, 9:00 AM
Talha Altınel (The Last Sith Lord)
Talha Altınel (The Last Sith Lord) - avatar
+ 1
That's nice, homework done, so now Arthur can go play.
13th Sep 2019, 9:14 AM
HonFu
HonFu - avatar
0
Perhaps he learnt something. Fingers crossed. I guess he will keep his HTML courses going
13th Sep 2019, 12:29 PM
Talha Altınel (The Last Sith Lord)
Talha Altınel (The Last Sith Lord) - avatar