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 »

6 comments

Click here for comments
suman
admin
25 August 2018 at 20:28 ×

nice article.thank you for you post.
visit
web programming tutorial
welookups

Reply
avatar
Akash G
admin
5 March 2019 at 00:12 ×

Nice ,visit studycodicodinginc.blogspot.com

Reply
avatar
suman
admin
4 August 2019 at 05:45 ×

nice article for beginners.thank you.
java tutorial

Reply
avatar
Dvivek
admin
25 September 2020 at 02:32 ×

great post it's very helpfully.
Dvivek

Reply
avatar
Anonymous
admin
7 December 2020 at 05:15 ×

Hey nice article about arrays in c programming explanation about array is good. Also read my article about arrays in c programming here.

Reply
avatar
27 January 2021 at 03:26 ×

nice article. for more programs in C language, you can check C programs

Reply
avatar
Thanks for your comment