ARRAYS in C programming language

ARRAY
   Array is a collection of homogeneous elements (elements of same data type), stored sequentially one after the other in memory. An element of an array can be accessed by using: name of the array and position of element in the array.
There are 2 types of Arrays, they are:
1. Single dimensional array
2. Multi dimensional array

1. Single dimensional array
              A single dimensional array is a linear list consisting of related elements of same type. In memory, all the elements are stored in continuous memory-location one after the other.
The Syntax of declaration of Single Dimensional Arrays:
              data_type array_name[array_size];

where
     data_type can be int, float, char or any valid built-in or user defined data type
     array_name is any valid identifier i.e name of the array
     array_size indicates number of elements in the array, it can be any valid integer expression.

For example:
        int marks[100];
        float temperature[365];
        char name[60]

2. Multi dimensional array
                   Arrays with two or more subscipts(dimensions/indices) are called multi dimensional arrays. It is widely used in matrix operations.
The Syntax of declaration of Multi Dimensional Arrays:
              Data_Type Array_Name[Row_Size][Col_Size];

Here we can note that Two Dimensional Arrays are "an array of One-Dimensional arrays of elements of same type". These are also called "Double Subscripted". Here a[ i ][ j ] refers to i-th Row and j-th Column element of 2D Array
Example:
      int a[3][4];

A two dimensional array is used when elements are arranged in a tabular fashion. Here, to identify a particular element, we have to specify 2 indices First index identifies the row number of the element and Second index identifies the column number of the element.

ARRAYS in C programming language ARRAYS in C programming language Reviewed by Unknown on 08:09 Rating: 5

No comments:

Powered by Blogger.