Array are three types in C language:
In this article we will talk about one-dimensional array in detail with its syntax and example and in upcoming article we will talk about another next two types of array in detail.
One Dimensional Array in C:
Those array in which the elements are accessible by the variable name assigned to the list and its subscript such array are know as a one-dimensional array in C.
Declaration of one dimensional Array :
Like other simple variable array should be declared beforer using in the program the syntax for one dimensional array in C is ,
datatype arrray_name[array size];
here array_name denote the name of the array and it can any valid C identifier,datatype is the data type of the element of array, the [size] of the array specifies the no of elements than can be stored in the array. it may be positive integer constant orconstant integer expression.
Example:- int age[10];
char a[5];
Initialization of 1-Dimensional Array:
After declaration, the element of local array have garbage value while the element of global and static array are automatically initialized to zero. The syntax of array for initialization is given below,
datatype array_name[size]={ value1,value2};
Example:- int marks[5]={ 1,2,3,4,5};
char a[5]={A,B,C};
Accessing 1-Dimensional Array Element:
The element of one dimensional array can be accessed by specifying the array name followed by subscript in bracket. In C the array subscript start from '0' and goes to (size of array-1) hence if there is an with size 3 then the valid subscript will be from with '0 to 2'.
And here, '0' is know as lower bond and 2 is know as upper bond of subscript of array.
Display 1-Dimensional Array Element:
For displaying one dimensional array element we generally use for for loop. The initial value of loop variable is taken zero since array index start from zero. The loop variable is increased by 1 each time. The total number of passes in the loop will be equal to the number of element in the array.

