C Programming Arrays
An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier.
An array is a data structure of multiple elements with the same data type. Array elements are accessed using subscript. The valid range of subscript is 0 to size -1.
One Dimensional Array
A list of items can be given one variable name using only one subscript and such a variable is called a single-subscripted variable or a one-dimensional array. In C, single-subscripted variable xi can be expressed as, x, x, x, x,…….,x[n]. The subscript can begin with number 0. For example if you want to represent a set of five numbers, say(35,40,20,57,19,45) by an array variable number, then you may declare the variable number as follows
and the computer reserves five storage locations as shown below:
The values to the array elements can be assigned as follows:
|number = 35|
|number = 40|
|number = 20|
|number = 57|
|number = 19|
|number = 45|
Declaration of One-Dimensional Array
The type specifies the type of element that will be contained in the array, such as int, char etc. and size indicates the maximum number of elements that can be stored inside the array for example. float matrix;