A two - dimensional M x N array A[M][N] is a collection or list of M x N data elements such that each element is specified by a pair of integers (such as J, K), called subscripts, with the property that

and LB of Column Index £ K £ UB of Column Index

In C/C++, lower bounds, LB, are zero. The element of A with first subscript J and second subscript K will be denoted by A [J][K].

Two–dimensional arrays are analogous to matrices in mathematics and tables in business. In it, data can be logically viewed as a table with columns & rows.

2–dimensional array can be declared as A[ 4] [5] in C/C++.

**direct **access.

Number of elements of 2–dim array =

(UB of row index – LB of row index + 1) x (UB of column index – LB of column index + 1)

In case of an array **A**[4] 5]

no. of elements = 4 x 5 = 20 (rows) x (column)

no. of bytes = no. of elements x bytes per element

= 20 x 2 bytes per data element = 40, if each element uses two memory bytes.

## No comments:

## Post a Comment