What is an array ?, Give an Example

Array is a collection of same data type. It is used to group same data type elements, such as rollnos, names of a class students etc. It is known as one of the data structure in C. To declate an array we should have prior info of data type and size of information.

Example:

To store marks of 10 subjects we can declare 10 size array of float data type.

floatĀ  marks[10];

Note:

In Array of size n index starts from 0 to n-1 . To access 5th element of array , it can be accesed by marks[4]. To access nth element in array it can be accessed at (n-1)th index.

%d bloggers like this: