C Programming + Tutorials in C for Beginners

C Arrays

Home  »  C Programming  »  C Arrays


     Array is similar type of data collection name i.e. it is a collection of same data type elements. An array is a group of related data items, which share common name. It is the set of homogeneous data.

Program without array having different variables:





Output is as :
20   30   40   50



Program with array having same variable name




Output is as :
How many number you want to enter: 5
Enter the 5 different elements in the array:
Enter the 5 different elements in the array:
20   30   40   50

Different array elements are:
20   30   40   50

      So array will solve the problem with the use of lesser number of variable and variable having the same name.

Types of Array

Linear Array

     This type of array is also called one Dimensional Array. This is also called list array. Another name of linear array is called single-dimensional array. These array are of ladder type. In the linear array only one subscript is used. It is written either in row or in column form.

The syntax to define or declare linear array is:

data-type arrary-name[size];


where data types are integer(int), real(float), double and character(char).
For example, some of the valid one dimensional array declaration statements are written as below:

int a[50];
float f[50];
char n[20];





Output is as :




Non-Linear Array

     Array of having different dimensions or n subscript is in the form of Non-linear array. Non-linear array are further of n different types as:

(a) Two Dimensional Array
(b) Three Dimensional Array
............................
(n) N-Dimensional Array


Two-Dimensional Array

     These arrays are also called double dimensional array. Another name of two-dimensional array is Tabular or Rectangular Array. These array are in row and column form, so these are also called Row-Column array or square array.

The syntax to define or declare two dimensional array is as:

data-type arrary-name[row size][column size];


For example, some of the valid one dimensional array declaration statements are written as below:

int a[10][10];
float f[50][50];
char n[20][20];





Output is as :




<< Previous Topic
Next Topic >>



Previous
Next Post »
Thanks for your comment