Friday, January 27, 2012

Arrays

Arrays fall under aggregate data type
Aggregate – More than 1
Arrays are collection of data that belong to same data type
Arrays are collection of homogeneous data
Array elements can be accessed by its position in the array called as index
Array index starts with zero
The last index in an array is num – 1 where num is the no of elements in a array
int a[5] is an array that stores 5 integers
a[0] is the first element where as a[4] is the fifth element
We can also have arrays with more than one dimension
float a[5][5] is a two dimensional array. It can store 5x5 = 25 floating point numbers The bounds are a[0][0] to a[4][4]