What Is Two-Dimensional Array?


Quick Answer

In computer programming, a two-dimensional array data structure is an array of values in which each value contains another array. A two-dimensional array greatly helps organize data for software to handle. The rows, columns and cells of a spreadsheet table is one way to visualize a two-dimensional array.

Continue Reading
Related Videos

Full Answer

Calling the name of an array along with an index key accesses a value from the array. These keys are numbers or descriptive words used to find the value. A two-dimensional array requires two keys to access a value. For example, a two-dimensional array of a hospital's patients contains the weight in pounds of each patient. John weighs 178, Susie weighs 129, Matt weighs 191 and so on. Depending on the language, the syntax of patient["john"]["weight"], patient["susie"]["weight"], patient["matt"]["weight"] and so on is one possible syntax for accessing each patient's weight.

Additionally, programming languages contain functions to work with multidimensional array data. While each language names and implements these functions differently, they are helpful tools for organizing complex array data. For example, PHP contains the array_multisort() function, which sorts multidimensional arrays.

While array support in assembly languages is nearly nonexistent, arrays are widely supported in high-level programming languages with multidimensional array support emerging in early languages, such as FORTRAN in 1957 and COBOL in 1960.

Learn more about Computer Programming

Related Questions