Computer Science[C++]

Data types are used to specify the type of data stored by a variable. To collect the various elements of the same type array is used. An array is mainly used for reducing the number of variables of same type that we require in a program. In C++, all arrays consist of contiguous memory locations.

Arrays are of different types, Single dimensional array and Two-dimensional array. Single dimensional array of string is used for storing and manipulating text, such as words, names and sentences. Two-dimensional array is the collection of data elements of same data type arranged in two dimensions, that is, rows and columns. C++ allows us to have arrays with dimensions more than two. The maximum limit of dimensions is compiler dependent.

C++ provides the facility of array initialisation at the time of declaration. C++ then automatically creates an array big enough to hold all the initialisers present. This is called an unsized array. In dynamic initialization of array, the elements are stored into the array during program run.

Strings are used for storing and manipulating text, such as words, names and sentences. C++ does not have a string data type, rather it is represented as an array of characters. A string is defined as a character array that is terminated by a null character.

Matrix is a set of mn numbers arranged in the form of a rectangular array of m rows and n columns represented through 2-D arrays. When an array is used as an argument to a function, only the address of the array gets passed, not a copy of the entire array. C++ interprets an array name as the address of its first element.

To Access the full content, Please Purchase