59 [51, 52, 53, 54, 55]]) |
59 [51, 52, 53, 54, 55]]) |
60 |
60 |
61 Pause the video here and make sure you have the arrays A and C, |
61 Pause the video here and make sure you have the arrays A and C, |
62 typed in correctly. |
62 typed in correctly. |
63 |
63 |
|
64 {{{ Pause the recording and type the arrays A,C }}} |
|
65 |
64 Let us begin with the most elementary thing, accessing individual |
66 Let us begin with the most elementary thing, accessing individual |
65 elements. Also, let us first do it with the one-dimensional array |
67 elements. Also, let us first do it with the one-dimensional array |
66 A, and then do the same thing with the two-dimensional array. |
68 A, and then do the same thing with the two-dimensional array. |
67 |
69 |
68 To access, the element 34 in A, we say, |
70 To access, the element 34 in A, we say, |
69 |
71 |
70 :: |
72 :: |
71 |
73 |
72 A[2] |
74 A[2] |
73 |
75 |
|
76 A of 2, note that we are using square brackets. |
|
77 |
74 Like lists, indexing starts from 0 in arrays, too. So, 34, the |
78 Like lists, indexing starts from 0 in arrays, too. So, 34, the |
75 third element has the index 2. |
79 third element has the index 2. |
76 |
80 |
77 Now, let us access the element 34 from C. To do this, we say |
81 Now, let us access the element 34 from C. To do this, we say |
78 :: |
82 :: |
79 |
83 |
80 C[2, 3] |
84 C[2, 3] |
|
85 |
|
86 C of 2,3. |
81 |
87 |
82 34 is in the third row and the fourth column, and since indexing |
88 34 is in the third row and the fourth column, and since indexing |
83 begins from zero, the row index is 2 and column index is 3. |
89 begins from zero, the row index is 2 and column index is 3. |
84 |
90 |
85 Now, that we have accessed one element of the array, let us change |
91 Now, that we have accessed one element of the array, let us change |