6. Initialization of Array
● Compile time
Initialize all specified memory locations
Partial array declaration
Initialization with all zeros
Initialization without size
● Run time
7. Initialize all specified memory locations
● int a[5]={1,2,3,4,5};
● Int a[3]={1,2,3,4,5};
// error
a[0] a[1] a[2] a[3] a[4]
16. Multi dimensional
● data_type array_name[d1][d2][d3][d4]………[dn];
● Where each d is a dimension, and dn is the size of final
dimension.
Examples:
● int table[5][5][20];
● float arr[5][6][5][6][5];
17. Example 1: int table[5][5][20];
● int represents the array type.
● table is the name of our 3D array.
● Our array can hold 500 integer-type elements. This
number is reached by multiplying the value of each
dimension. In this case: 5x5x20=500.
Example 2: float arr[5][6][5][6][5];
● Array arr is a five-dimensional array.
● It can hold 4500 floating-point elements
(5x6x5x6x5=4500).
18. ● single array can hold thousands of values.
● 3D array is essentially an array of arrays of arrays
● it's an array or collection of 2D arrays, and a 2D
array is an array of 1D array.
●
19. ● To call values from the array
25 located in table 1, row 1, and column 1, hence the
address is arr[1][1][1].