# Need a bit explanation!!

• 04-16-2005
cBegginer
Need a bit explanation!!
How does 2d matrix print to the output? i means if i got a[7][7]
Will it on the first line of the output from left to right or from top to bottom??
For example
Code:

```int sum; for (i=1; i <= 7; ++i) {   for (j=1; j <= 7; ++j)   ......  }```
i think output should be :
1 2 3 4 5 6 7
1 2 3 4 5 6 7
1 2 3 4 5 6 7
1 2 3 4 5 6 7
1 2 3 4 5 6 7
1 2 3 4 5 6 7
1 2 3 4 5 6 7

It prints left to right first or bottom all the 1 first then 2...thanks
• 04-16-2005
bithub
Well it depends on if you are doing
Code:

`matrix[i][j]`
or
Code:

`matrix[j][i]`
Basically, it is your choice on how you represend the 2D array. There is no rule that i's represent rows, and j's represent columns :)
• 04-16-2005
Salem
> i means if i got a[7][7]
Then the loop is
for (i=0; i < 7; ++i)

Not
for (i=1; i <= 7; ++i)
• 04-16-2005
an array of size 7 would have 7 elements.
thus there would be 7 valid indices: 0, 1, 2, 3, 4, 5, 6.
the highest valid index is array_size - 1

thus: yes, for (i=0; i < 7; ++i) is correct -
also correct would be for (i=0; i <= 6; ++i)
• 04-17-2005
cBegginer
oo..ok..thanks for helping..