About arrays | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

About arrays

Can someone please tell me how is arr[ ] [ ] value is calculated

14th Dec 2019, 3:29 AM
kunal beri
kunal beri - avatar
1 Answer
+ 3
Let us assume that we have a matrix. arr [i][j]; Now considering i = j = 3 arr [3][3]; // 3×3 matrix Row 0-> 1 2 3 Row 1-> 4 5 6 Row 2-> 7 8 9 Similarly mark the columns from 0 to 2. Though you have the size as 3 by 3 but the indexing starts from 0 to 2 in this case. Element at row 0 & column 0 is 1 OR arr[0][0] = 1 Element at row 0 & column 1 is 2 OR arr[0][1] = 2 Element at row 0 & column 2 is 3 OR arr[0][2] = 3 And so on....
14th Dec 2019, 5:53 AM
Avinesh
Avinesh - avatar