Arrays and String

Arrays

Arrays and String


Arrays are the collection of homogeneous elements such that the elements are stored 
in consecutive memory locations or we can say that the "Array is a collection of variables of the same type of data that are reffered by a common name , These elements are referenced respectively by an index set consisting of 'n' consecutive numbers.



     
     Size of array is the number 'n' of elements. The index set consisting of consecutive Integers 1,2,3...................., n.

The lowest address of an array corresponds to the first element and the highest address to the last element. The size or length can be obtained as follows :-

                     length = in - lb + 1

Where ' ub' is the upper bound and it refers to the largest index  while 'lb' is the lower bound and it refers to the smallest index of an array respectively. When 'lb' is equal to 1 then in this case length of any array is equal to as ub = 1.



The elements of an array N may be denoted by the subscription notation -


N1, N2, N3, ..........Nk, ...........Nn

In Paranthesis Notation -

{ N1 , N2 , N3, ...........Nn}

The number k is called the subscript of an array while  "N[K]" is reffered as subscripted variable. The subscript notation or the bracket one is generally used by the user. The subscript allow any element of N to be referenced by its relative position in N . The most common array is the " null - terminated String".  Which is simply an array of characters ended by a null or zero.


Main Postulates about Arrays :-

There are some important points to be pointed out about arrays. These are as follows :-

(1) Array are always stored in                 consecutive memory locations.

(2) An array can store multiple values which can be referenced by a single name unlike a simple variable which store one value at a time followed by an index or subscript, specified inside a squre bracket.

(3) Array name is actually a pointer to the first location of the memory block allocated to the name of the array.

(4) An array either be a integer , character or floting data type can be initialised only during declaration time and not afterwards.

(5) There is no bound checking consept  for arrays in C.








Thank You......




Comments

Popular posts from this blog

Array Declaration

Data Structure and C

Description of Various Data Structures