Page 13 - PROGRAMMING IN C_Neat
P. 13
Example:
for( i=0; i<10; i++ )
{
_ _ _
_ _ _
if(a < 0)
continue;
_ _ _
_ _ _
}
_______________________________________________________________________________________
6. Explain one dimensional array. *
One Dimensional Array:
Contains one subscript.
General Form:
array_name[subscript]
Example:
a[0]
One Dimensional Array – Declaration:
General Form:
datatype array_name[size];
Example:
int a[3];
One Dimensional Array – Initialization:
General Form:
static datatype array_name[size] = {list of values};
Example:
static int a[3] = {10, 20, 30};
Memory Storage:
a[0] a[1] a[2]
10 20 30
_______________________________________________________________________________________
7. Explain two dimensional array. *
Two Dimensional Array:
Contains two subscripts.
General Form:
Example: array_name[subscript1][subscript2]
a[0][0]
Two Dimensional Array – Declaration:
General Form:
datatype array_name[rowsize][columnsize];