Add paragraph "Two-dimensional Array" (#26347)

* Add paragraph "Two-dimensional Array"

* Fix formatting
This commit is contained in:
maidak95
2019-02-05 20:00:01 +01:00
committed by Manish Giri
parent 04d711543b
commit 98473c2582

View File

@ -31,7 +31,22 @@ int numbers [5] = {6};
//Initialization with declaration: //Initialization with declaration:
int numbers [] = {1, 2, 3, 4, 5}; int numbers [] = {1, 2, 3, 4, 5};
//Note that here the number of values defines the size of the array. //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 ## Types Of Arrays
There are two types of arrays based on way the array is declared. There are two types of arrays based on way the array is declared.