Array
Array is a container which can hold a fix number of items and these items should be of the same type. Most of the data structures make use of arrays to implement their algorithms. Following are the important terms to understand the concept of Array.
-
Element − Each item stored in an array is called an element.
-
Index − Each location of an element in an array has a numerical index, which is used to identify the element.
Basic Operations
Following are the basic operations supported by an array.
- Traverse − print all the array elements one by one.
- Insertion − Adds an element at the given index.
- Deletion − Deletes an element at the given index.
- Search − Searches an element using the given index or by the value.
- Update − Updates an element at the given index.
In C, when an array is initialized with size, then it assigns defaults values to its elements in following order
Data Type | Default Value |
---|---|
bool | false |
char | 0 |
int | 0 |
float | 0.0 |
double | 0.0f |
void | void |
wchar_t | 0 |