Introduction: |
There are many Applications which require to process a group of Data items that are of same type such as double , float , int or char.
For example:
we can define an Array of a list of marks obtained in an Examination by a group of Students. In such a situation, it is necessary to have a unique variable which holds a group of elements.
Definition: |
- Array is a group of Homogeneous data type elements, that consumes a continous Memory Area.
- Array is used for Multiple inputs in a single variable.
- An Array is a Data structure which stores a group of elements of the same kind.
- Array can also be defined as an ordered list of Homogenous data elements.
Note: Subscript must be an unsigned Positive Integer.
Classification of Arrays: |
- One-dimensional array
- Multi-dimensional arrays
- Two-dimensional array
- Three-dimensional array
Note: The dimensionality is determined by the number of subscripts in an array. If there is one subscript, then Array is One-dimensional. If there are two subscripts , then Array is Two-dimensional and so on.
Declaration of Arrays: |
Array must be declared by using the Data Type before it appears in the Program. At the same time of declaration, the size of an Array must also be specified with in a pair of square brackets. This allows the Compiler to decide on how much memory is to be reserved for the Array.
Rules for Subscripts: |
- Each subscript must be a positive integer constant or an expression.
- Nesting of subscripts not allowed i.e [ [ ] ] .
- The maximum subscript appearing in a program for subscripted variable should not exceed the declared one. Example: int A[5] , The subscripts for the array A should not be exceed from 5.
- C does not perform bounds checking.
- The subscript value ranges from 0 to one less than the size of array. Example: If the size of an array is 10, then the First subscript is 0 and the Last subscript is 9.
Note: An ordinary variable can hold only single data value where as Array can store multiple data values of same data type.
0 Response to "Detailed Discription of C Language Array [Tutorial]"
Post a Comment