Define Array
Define Array
Answer: an array is a collection of a fixed number of elements of the same data type, stored in consecutive memory locations and referred to by a single name.
Each element is accessed using the array name and an index (subscript) in square brackets. In C the index starts at 0.
int marks[5] = {45, 67, 89, 72, 50};
Here marks holds 5 integers: marks[0] is 45, marks[1] is 67, ..., marks[4] is 50.
Instead of declaring five separate variables, one array stores all the values, and a loop can process them easily. Arrays can be one-dimensional (a list) or multi-dimensional (e.g. a 2-D array for a matrix).
Log in or create a free account to answer this question.