Add paragraph "Two-dimensional Array" (#26347)
* Add paragraph "Two-dimensional Array" * Fix formatting
This commit is contained in:
@ -31,7 +31,22 @@ int numbers [5] = {6};
|
||||
//Initialization with declaration:
|
||||
int numbers [] = {1, 2, 3, 4, 5};
|
||||
//Note that here the number of values defines the size of the array.
|
||||
//In the examples above, the size was fixed at compile time
|
||||
|
||||
// In the examples above, the size was fixed beforehand
|
||||
```
|
||||
|
||||
## Two-Dimensional Arrays
|
||||
|
||||
The simplest form of the multidimensional array is the two-dimensional array. A two-dimensional array is, in essence, a list of one-dimensional arrays. To declare a two-dimensional integer array of size `x*y`, you would write something as follows −
|
||||
`type arrayName [ x ][ y ]`;
|
||||
|
||||
```C++
|
||||
int a[3][4] = {
|
||||
{0, 1, 2, 3} , /* initializers for row indexed by 0 */
|
||||
{4, 5, 6, 7} , /* initializers for row indexed by 1 */
|
||||
{8, 9, 10, 11} /* initializers for row indexed by 2 */
|
||||
};
|
||||
|
||||
```
|
||||
## Types Of Arrays
|
||||
There are two types of arrays based on way the array is declared.
|
||||
|
Reference in New Issue
Block a user