Definitin fo Array
“The collection of homogenous data
elements stored under a single name in consecutive memory locations.”
This single name is called array. Individual
elements of array are called SUB-SCRIPTED
variables. Thus a sub-scripted variable consists of an array name followed by
sub-script of an index enclosed in square bracket. A pair of bracket is used
for sub-script. Array may be one dimensional one dimensional or two
dimensional.
TYPES
OF ARRAY:
2.TWO DIMENSIONAL ARRAY
§ ONE DIMENSIONAL ARRAY:
This type of array is also called linier
array. In this, there is only one sub-script. Each element of array is stored
in consecutive location in memory as
Data type array name
size
int a[10] = (1,2,3,4,5,6,7,8,9,10)
§ TWO DIMENSIONAL ARRAY:
It
is also called 2-D array. It is also called MATRIX because it contains rows and
columns. This type of array consists of two sub-scripts. First sub-script
represents rows and second sub-script represents columns. It is also called m*n
matrix. Here, ‘m’ represents rows & ‘m’ represents columns.
EXAMPLE:
a
[3] [3]
MEMORY REPRESENTATION
§ ROW
BY ROW
§ COLUMN
BY COLUMN
Comments
Post a Comment