Array in C || C Language

Array in C

by Yogesh Khanna 23-Aug-18

0 1185

An array in C language is a collection of same data types. The size of an array must be a constant value.

The syntax for C arrays:

int a[20]; // integer array
char b[10]; // character array

Example of Array

If anyone wants to store marks of 200 students, he/she can create an array for it.

For eg. Float marks[200];

Once size and type of the array are declared, it will be fixed.

Decalaration of Array

Data-type array_name[array_size];


int a[20]; // integer array
char b[10]; // character array

float marks[200]; // float array

In these examples, we declared arrays a,b, marks of integer, character and floating-point type and size 20,10,200 respectively.

Initialisation of Array

You can initialize array while declaration.

For e.g.

int mark[2] ={24,15};


int mark[]={24,25};

Important Note

Suppose, we have declared an array of 5 elements. Let's say,

int marks [5];

We can use the array members from marks[0] to marks[4].If anyone tries to access out of this bound, there may occur unexpected output.

One-dimensional Array

It is known as the linear array and while accessing it involves single subscripts that can be row or column.

Syntax: datatype name of an array[sizeofArray];

int marks[5];

Two Dimensional Array

The Two-dimensional array is an extension of a one-dimensional array. These arrays consist of two subscripts and we often call it an array of the array also. In this, there is a division of array occurs i.e. rows and columns and applicable for handling tabular data.

Syntax: data_type array_name[row_size][column_size];


int arr[4][4];

in this example, first index display the rows and second index display columns of the array.

Multi dimensional Array

The array of arrays is another name of multi-dimensional Array. It is identical to the two-dimensional array but it can be three-dimensional arrays.


data_type array_name[size1][size2][size3]--[sizeN];

Example of an Array in C programming language is below:

int main()

int i, number[5];

printf("Enter 5 number \n");
scanf("%d", %numbers[i]);

printf("Array elements are \n");

return 0;



Discount Coupons

Leave a Reply

    Waiting for your comments