Arrays in c language:
An array in c language is collection of data of similar datatype that is the collection can be of type, integer, float, character,.double etc
the syntax for representing array in c language is :
datatype collectionname ;
eg: int numbers[10]
Char vowels[5]
Float heights[20]
Here numbers is a collection of data type int and as total 10 no, of elements in collection, vowels is a collection of data type char and as total 5 no, of elements in collection and heights is a collection of data type float and as total 20 no, of elements in collection
The interesting point to not here is that the elements of array of a collection are stored in successive memory locations depending on datatype of collection
C language treats the name of collection as a pointer to access values in an array Each element in an array has an index value associate with it which starts from zero
Foe example in int numbers[10], which can have at most ten elements are stored in numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], numbers[6], numbers[7], numbers[8], numbers[9] locations.
see various programs at :
http://www.itstudentjunction.com/c-programs.htm
Initiatialization of arrays:
No comments:
Post a Comment