Two-dimensional array: A two dimensional array is also called as a multi-dimensional array; a multidimensional array is that all the identical arrays are put together into a single array. This is useful for storing same type of multiple sets of data in same place. The main advantage is that one-dimensional array can hold only one set of value whereas two-dimensional array can hold multiple sets of data in the form of rows and columns. The structure of a multi-dimensional array is lookalike a table (that is combination of rows and columns); it contains same type of columns. Syntax: The syntax of two dimensional arrays is as follows: datatype array_name [number_of_rows][number_of_columns]; Analyzing the given array definition: Consider the given array definition: //Declare the two-dimensional array int numberArray[9][11]; The above code illustrates that the declaration of a two dimensional array named “numberArray” which holds “6” rows and “4” columns; so totally the array can hold “99” elements (that is 9 × 11 = 99 ). The index number representation for the “99” elements are as follows: C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 R1 (0,0) (0,1) (0,2) (0,3) (0,4) (0,5) (0,6) (0,7) (0,8) (0,9) (0,10) R2 (1,0) (1,1) (1,2) (1,3) (1,4) (1,5) (1,6) (1,7) (1,8) (1,9) (1,10) R3 (2,0) (2,1) (2,2) (2,3) (2,4) (2,5) (2,6) (2,7) (2,8) (2,9) (2,10) R4 (3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7) (3,8) (3,9) (3,10) R5 (4,0) (4,1) (4,2) (4,3) (4,4) (4,5) (4,6) (4,7) (4,8) (4,9) (4,10) R6 (5,0) (5,1) (5,2) (5,3) (5,4) (5,5) (5,6) (5,7) (5,8) (5,9) (5,10) R7 (6,0) (6,1) (6,2) (6,3) (6,4) (6,5) (6,6) (6,7) (6,8) (6,9) (6,10) R8 (7,0) (7,1) (7,2) (7,3) (7,4) (7,5) (7,6) (7,7) (7,8) (7,9) (7,10) R9 (8,0) (8,1) (8,2) (8,3) (8,4) (8,5) (8,6) (8,7) (8,8) (8,9) (8,10) With the help of assignment operator “=”, the value can be easily assigned to an array.
Two-dimensional array: A two dimensional array is also called as a multi-dimensional array; a multidimensional array is that all the identical arrays are put together into a single array. This is useful for storing same type of multiple sets of data in same place. The main advantage is that one-dimensional array can hold only one set of value whereas two-dimensional array can hold multiple sets of data in the form of rows and columns. The structure of a multi-dimensional array is lookalike a table (that is combination of rows and columns); it contains same type of columns. Syntax: The syntax of two dimensional arrays is as follows: datatype array_name [number_of_rows][number_of_columns]; Analyzing the given array definition: Consider the given array definition: //Declare the two-dimensional array int numberArray[9][11]; The above code illustrates that the declaration of a two dimensional array named “numberArray” which holds “6” rows and “4” columns; so totally the array can hold “99” elements (that is 9 × 11 = 99 ). The index number representation for the “99” elements are as follows: C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 R1 (0,0) (0,1) (0,2) (0,3) (0,4) (0,5) (0,6) (0,7) (0,8) (0,9) (0,10) R2 (1,0) (1,1) (1,2) (1,3) (1,4) (1,5) (1,6) (1,7) (1,8) (1,9) (1,10) R3 (2,0) (2,1) (2,2) (2,3) (2,4) (2,5) (2,6) (2,7) (2,8) (2,9) (2,10) R4 (3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7) (3,8) (3,9) (3,10) R5 (4,0) (4,1) (4,2) (4,3) (4,4) (4,5) (4,6) (4,7) (4,8) (4,9) (4,10) R6 (5,0) (5,1) (5,2) (5,3) (5,4) (5,5) (5,6) (5,7) (5,8) (5,9) (5,10) R7 (6,0) (6,1) (6,2) (6,3) (6,4) (6,5) (6,6) (6,7) (6,8) (6,9) (6,10) R8 (7,0) (7,1) (7,2) (7,3) (7,4) (7,5) (7,6) (7,7) (7,8) (7,9) (7,10) R9 (8,0) (8,1) (8,2) (8,3) (8,4) (8,5) (8,6) (8,7) (8,8) (8,9) (8,10) With the help of assignment operator “=”, the value can be easily assigned to an array.
A two dimensional array is also called as a multi-dimensional array; a multidimensional array is that all the identical arrays are put together into a single array.
This is useful for storing same type of multiple sets of data in same place.
The main advantage is that one-dimensional array can hold only one set of value whereas two-dimensional array can hold multiple sets of data in the form of rows and columns.
The structure of a multi-dimensional array is lookalike a table (that is combination of rows and columns); it contains same type of columns.
Syntax:
The syntax of two dimensional arrays is as follows:
The above code illustrates that the declaration of a two dimensional array named “numberArray” which holds “6” rows and “4” columns; so totally the array can hold “99” elements (that is
9×11=99).
The index number representation for the “99” elements are as follows:
C1
C2
C3
C4
C5
C6
C7
C8
C9
C10
C11
R1
(0,0)
(0,1)
(0,2)
(0,3)
(0,4)
(0,5)
(0,6)
(0,7)
(0,8)
(0,9)
(0,10)
R2
(1,0)
(1,1)
(1,2)
(1,3)
(1,4)
(1,5)
(1,6)
(1,7)
(1,8)
(1,9)
(1,10)
R3
(2,0)
(2,1)
(2,2)
(2,3)
(2,4)
(2,5)
(2,6)
(2,7)
(2,8)
(2,9)
(2,10)
R4
(3,0)
(3,1)
(3,2)
(3,3)
(3,4)
(3,5)
(3,6)
(3,7)
(3,8)
(3,9)
(3,10)
R5
(4,0)
(4,1)
(4,2)
(4,3)
(4,4)
(4,5)
(4,6)
(4,7)
(4,8)
(4,9)
(4,10)
R6
(5,0)
(5,1)
(5,2)
(5,3)
(5,4)
(5,5)
(5,6)
(5,7)
(5,8)
(5,9)
(5,10)
R7
(6,0)
(6,1)
(6,2)
(6,3)
(6,4)
(6,5)
(6,6)
(6,7)
(6,8)
(6,9)
(6,10)
R8
(7,0)
(7,1)
(7,2)
(7,3)
(7,4)
(7,5)
(7,6)
(7,7)
(7,8)
(7,9)
(7,10)
R9
(8,0)
(8,1)
(8,2)
(8,3)
(8,4)
(8,5)
(8,6)
(8,7)
(8,8)
(8,9)
(8,10)
With the help of assignment operator “=”, the value can be easily assigned to an array.