Sei sulla pagina 1di 2

Array:

it is used to store the collections of data with similar datatype.

it is of two type:

i. single dimensional array


ii. multidimensional array

single :

it contains only one row and 'n' number of columns

syntax:

declare:

datatype arrayname[size];

eg:

int a[5];

initialization:

arrayname[indexing position]=value;

eg:

a[0]=10;
a[1]=20;
a[2]=30;
a[3]=40;
a[4]=50;

multidimensional :

it contains 'n' number of rows and 'n' number of columns.

syntax:

datatype arrayname[number of rows][number of columns];

eg:

int a[2][2];

initialize:

syntax:

arrayname[indexingposition of rows][indexing position of columns]=value;

eg:

a[0][0]=100;
a[0][1]=200;
a[1][0]=300;
a[1][1]=400;

int a[3]={10,20,30};

int a[2][2]={{10,20},{30,20}};

Potrebbero piacerti anche