From 98473c25828e004a8c67ad10607279521b369c86 Mon Sep 17 00:00:00 2001 From: maidak95 <44378644+maidak95@users.noreply.github.com> Date: Tue, 5 Feb 2019 20:00:01 +0100 Subject: [PATCH] Add paragraph "Two-dimensional Array" (#26347) * Add paragraph "Two-dimensional Array" * Fix formatting --- guide/english/cplusplus/arrays/index.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/guide/english/cplusplus/arrays/index.md b/guide/english/cplusplus/arrays/index.md index 5adb24bd43..452c040bf4 100644 --- a/guide/english/cplusplus/arrays/index.md +++ b/guide/english/cplusplus/arrays/index.md @@ -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.